BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
yashraj89
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
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;
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
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;
--
Paige Miller
yashraj89
Obsidian | Level 7

Thanks Paige Miller. It worked like gem.

novinosrin
Tourmaline | Level 20

Hi @yashraj89  Requesting you to please mark the solution as answered and close the thread

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 13770 views
  • 0 likes
  • 3 in conversation