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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.