Ex: Data. Trt; Pid = 100; Drug = ’col 5 mg’; Sdate = ‘12oct2003’d; Stime=’13:23:34’t; Ed time =’14dec2003; 10:12:23’dt; Run; Proc print data =trt; Format sdate word date 18. Stime time8. Edate date time 18.; run; ex; /* extraction */ Data one; Infile ‘d:\medi.txt’; Input pid drug $; Run; /* transformation and loading*/ Data medi; Set one; Group =’G100’; -> constant value loading If drud = ‘col 5 mg’ Then u date =’12 oct 2006’d; Else If drud = ‘col 10 mg’ Then u date =’12 oct 2006’d +30; Else u date =’12 oct 2006’d +60; Format udate date 9; Run; Proc print data =medi; Run;
Learn the core features of SAS and become master with our expertise SAS Training and Placement.
Ex: Data demo; i=100; dowhile (i<=120); pid = I; output; i =i+1; End; Drop i; Run; Proc print data =demo; Run;
Ex: Data demo; i=100; do until(i>120); pid = I; output; i =i+1; End; Drop i; Run; Proc print data =demo; Run; Ex: Data demo; i=100; do while (i<=150); pid = I; output; i=i+2; End; Drop i; Run; Proc print data =demo; Run; Do loop, work like a do while loop but we can write all loop requirements in single statement. Ex: Data demo; Do i =100 to 150 by 2; pid = I; output; End; Drop i; Run; Proc print data =demo; Run;
Using single trail method we can hold the SAS system at the end of the SAS session. But we can’t run trail methods multiple times. Ex: Data medi; Input pid visit drug $ @; output; Input visit drug $ @ ; output; Input visit drug $ @ ; output; Input visit drug $ @ ; output; Cards; 100 1 5mg 2 5mg 3 10 mg 4 15 mg 100 1 10mg 2 10mg 3 15 mg 4 15 mg ; Proc print data = medi; Run; (or) Data medi 1; Input visit drug $ @ ; output; Do i= 1 to 3; Input visit drug $ @ ; output; End; Drop i; Cards; 100 1 5mg 2 5mg 3 10 mg 4 15 mg 100 1 10mg 2 10mg 3 15 mg 4 15 mg ; Proc print data = medi; Run; Ex: Data medi; Input pid drug $ @ ; output; Do i= 1 to 2; Input drug $ @ ; output; End; Drop i; Cards; 1 col 5 mg col10 mg col 15 mg 2 col 5 mg col10 mg col 15 mg … … 10 col 5 mg col10 mg col 15 mg Run; Proc print data = medi; Run;
You liked the article?
Like : 0
Vote for difficulty
Current difficulty (Avg): Medium
1/15
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.
Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox