Wednesday, 12 October 2011

SAS - Strings SQL


proc import datafile='C:\Documents and Settings\mobileclub\Desktop\source\xls\data.xls'
out=demo1 dbms=excel replace;
sheet='sheet1$';
run;
proc sql;
select fname,
length(fname) as len,
index(fname, 'a') as ind1,
index(fname,'rao') as ind2,
scan(fname,3) as sc,
upcase(fname) as up,
compress(fname,'a') as comp1,
compress(fname) as comp2
 from demo1;
quit;
proc sql;
select fname,
compress(fname) as comp2,
substr(fname,3,10) as sub1,
substr(fname,3) as sub2
 from demo1;
 quit;
proc import datafile='C:\Documents and Settings\mobileclub\Desktop\source\xls\data.xls'
out=mh dbms=excel replace;
sheet='sheet3$';
run;
proc sql;
select pid,drug,dose,scan(adevents,1) as ae,
scan(adevents,2) as adr from mh;
quit;
proc import datafile='C:\Documents and Settings\mobileclub\Desktop\source\xls\data.xls'
out=mh1 dbms=excel replace;
sheet='sheet2$';
run;
proc sql;
select pid,drug ||'-'||dose as treatment from mh1;
quit;

No comments:

Post a Comment