Hello! I have a small problem that I would like to submit to you.
I have a list of tables named A_202201 to A202252 then A_202301 and A_202302. In fact, A_202201 corresponds to the table of week 01 of the year 2022 and so on. So we will have in the coming weeks other tables like A_202303 ...
I want to merge these tables by making a loop but I can't do it. Here is the program:
data total_A;
merge do j=&minsem0 to &maxsem1-1;
where &j not in 202253 to 202300;
A_&j
end;;
by genotypageCourant_info;
run;
Can anyone help me?
See the example by @Ksharp in this https://communities.sas.com/t5/SAS-Programming/macro-do-loop-to-append-monthly-dataset/m-p/853142#M3...
Which allows use of interval lists. The
options nodsnferr;
means that a list like
data total_A; merge a_202253 - a_202302; by genotypageCourant_info; run;
can be used where the gaps in a sequence that would normally generate an error doesn't.
That list will attempt to use a_202253 a_202254 a_202255 a_202256 etc to a_202299 a_202300. Normally the default option of DSNFERR would throw an error if any of the values in the list aren't present.
Are you certain that you want to use MERGE and not SET ?
Yes, it is MERGE that I use. the program was running correctly before the year change
In that case, here is an alternative.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/n0oru3akf51pi5n1wco2onzr39oz.htm
merge A_2022: A_2023: ;
The colon includes all existing data set names that begin with A_2022 and A_2023, so be sure that that you want all of them before using this.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.