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

I failed to use do loop in the following statement.

 

Label

date_csop1 = 'Date case opened, event1' date_csop2 = 'Date case opened, event2'
date_csop3 = 'Date case opened, event3' date_csop4 = 'Date case opened, event4'
date_csop5 = 'Date case opened, event5' date_csop6 = 'Date case opened, event6'
date_csop7 = 'Date case opened, event7' date_csop8 = 'Date case opened, event8'
date_csop9 = 'Date case opened, event9' date_csop10 = 'Date case opened, event10'

 

date_cscls1 = 'Date case closed, event1' date_cscls2 = 'Date case closed, event2'
date_cscls3 = 'Date case closed, event3' date_cscls4 = 'Date case closed, event4'
date_cscls5 = 'Date case closed, event5' date_cscls6 = 'Date case closed, event6'
date_cscls7 = 'Date case closed, event7' date_cscls8 = 'Date case closed, event8'
date_cscls9 = 'Date case closed, event9' date_cscls10 = 'Date case closed, event10' ;

1 ACCEPTED SOLUTION

Accepted Solutions
Barkat
Pyrite | Level 9

Thanks,

The following statement worked.

 

%MACRO DO_LABEL(count);
%DO Y = 1 %TO &count;
date_csop&Y = "Date case opened, event&Y"
date_cscls&Y = "Date case closed, event&Y"
%END;
%MEND DO_LABEL;
LABEL %DO_LABEL(10);

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

A data step do loop will not work here but a macro with a %DO loop could work.

 
--
Paige Miller
Barkat
Pyrite | Level 9

Thanks,

The following statement worked.

 

%MACRO DO_LABEL(count);
%DO Y = 1 %TO &count;
date_csop&Y = "Date case opened, event&Y"
date_cscls&Y = "Date case closed, event&Y"
%END;
%MEND DO_LABEL;
LABEL %DO_LABEL(10);

Reeza
Super User

If this data is generated via a TRANSPOSE you may also want to take advantage of the IDLABEL option. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 900 views
  • 2 likes
  • 3 in conversation