Hi
I am trying to create a dummy dataset based on the number of cycles I have in the dataset. Right now I am writing sas code to create each observation individually. I want the repetition to automate rather than writing the whole code. In the below piece of code i am creating the same 8 records for all the cycles. I want to create these records for 50 cycles but i dont want to write 400 lines of sas code.
data pcn;
length pktpt_std $30 visit $30 ;
do cyc =2; pktpt_std='PRE-DOSE'; visit='C2 D1'; output; end;
do cyc =2; pktpt_std='5 MIN POST'; visit='C2 D1'; output; end;
do cyc =2; pktpt_std='PRE-DOSE'; visit='C2 D8'; output; end;
do cyc =2; pktpt_std='5 MIN POST'; visit='C2 D8'; output; end;
do cyc =2; pktpt_std='PRE-DOSE'; visit='C2 D15'; output; end;
do cyc =2; pktpt_std='5 MIN POST'; visit='C2 D15'; output; end;
do cyc =2; pktpt_std='PRE-DOSE'; visit='C2 D22'; output; end;
do cyc =2; pktpt_std='5 MIN POST'; visit='C2 D22'; output; end;
do cyc =3; pktpt_std='PRE-DOSE'; visit='C3 D1'; output; end;
do cyc =3; pktpt_std='5 MIN POST'; visit='C3 D1'; output; end;
do cyc =3; pktpt_std='PRE-DOSE'; visit='C3 D8'; output; end;
do cyc =3; pktpt_std='5 MIN POST'; visit='C3 D8'; output; end;
do cyc =3; pktpt_std='PRE-DOSE'; visit='C3 D15'; output; end;
do cyc =3; pktpt_std='5 MIN POST'; visit='C3 D15'; output; end;
do cyc =3; pktpt_std='PRE-DOSE'; visit='C3 D22'; output; end;
do cyc =3; pktpt_std='5 MIN POST'; visit='C3 D22'; output; end;
run;
thanks
data want;
length pktpt_std $ 10 vist $ 10;
do cyc=1 to 50;
do num=1, 1, 8, 8, 15, 15, 22, 22;
do pktpt_std='PRE-DOSE', '5 MIN POST';
visit=cats('C', cyc)||' '||cats('D', num);
output;
end;
end;
end;
run;
data want;
length pktpt_std $ 10 vist $ 10;
do cyc=1 to 50;
do num=1, 1, 8, 8, 15, 15, 22, 22;
do pktpt_std='PRE-DOSE', '5 MIN POST';
visit=cats('C', cyc)||' '||cats('D', num);
output;
end;
end;
end;
run;
Thanks Paige Miller. It worked like gem.
Hi @yashraj89 Requesting you to please mark the solution as answered and close the thread
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: