/*coalesce*/
data dm;
input pid age treatment $;
cards;
101 . study
102 25 study
103 . study
104 24 .
105 34 study
;
proc sql;
select pid ,coalesce (age,18) as age,
coalesce (treatment,'study') as treatment from dm;
quit;
proc sql;
update dm set age=18 where age=.;
update dm set treatment='study' where treatment=' ';
quit;
proc sql;
select pid, case when age=. then 18 else age end as age,
case when treatment=' ' then 'study' else treatment end as treatment from dm;
quit;
data employ;
input id des $;
cards;
101 programer
102 analyst
102 qc
101 tester
;
proc sql;
select distinct(id) as id from employ;
quit;
data customers;
infile'C:\Documents and Settings\mobileclub\Desktop\source\DLM\customers.txt';
input cno $ bcd $ pcd $ month goods;
run;
proc sql;
select distinct (cno) as cs 'customer list' from customers;
quit;
proc sql;
select distinct (bcd) as bs 'branch list' from customers;
quit;
proc sql;
select distinct (pcd) as ps 'produclist' from customers;
quit;
No comments:
Post a Comment