Hello all, I have the below code and would like to make it more concise. It could be macro, do-loop or other ways. Thank you in advance.
data abc;
set abc;
date1 = intnx('day', start_date, 20);
date2 = intnx('day', date1, 20);
date3 = intnx('day', date2, 20);
date4 = intnx('day', date3, 20);
date5 = intnx('day', date4, 20);
date6 = intnx('day', date5, 20);
date7 = intnx('day', date6, 20);
run;
data abc_new;
set abc;
array _dates(*) date1-date7;
do i=1 to dim(_dates);
_dates(i) = intnx('day', start_date, 20*i);
end;
run;
Here's a tutorial on using Arrays in SAS
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/
@di_niu0 wrote:
Hello all, I have the below code and would like to make it more concise. It could be macro, do-loop or other ways. Thank you in advance.
data abc;
set abc;
date1 = intnx('day', start_date, 20);
date2 = intnx('day', date1, 20);
date3 = intnx('day', date2, 20);
date4 = intnx('day', date3, 20);
date5 = intnx('day', date4, 20);
date6 = intnx('day', date5, 20);
date7 = intnx('day', date6, 20);
run;
data abc_new;
set abc;
array _dates(*) date1-date7;
do i=1 to dim(_dates);
_dates(i) = intnx('day', start_date, 20*i);
end;
run;
Here's a tutorial on using Arrays in SAS
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/
@di_niu0 wrote:
Hello all, I have the below code and would like to make it more concise. It could be macro, do-loop or other ways. Thank you in advance.
data abc;
set abc;
date1 = intnx('day', start_date, 20);
date2 = intnx('day', date1, 20);
date3 = intnx('day', date2, 20);
date4 = intnx('day', date3, 20);
date5 = intnx('day', date4, 20);
date6 = intnx('day', date5, 20);
date7 = intnx('day', date6, 20);
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.