BookmarkSubscribeRSS Feed
Michael_W
Fluorite | Level 6
I am stuck and I am hoping one of the many SAS guru can assist me. I am trying to dymanically generate several .sas files that are incrementally named (e.g. PRG01.SAS, PRG02.SAS, etc.) and each of which contains slightly different contents (e.g. PRG01.SAS contains Data WORK.TMP01; Set MYTBL (FirstObs=1 OBS=1000000); run; and PRG02.SAS contains Data WORK.TMP01; Set MYTBL (FirstObs=10000001 OBS=2000000); run;)

The FIRSTOBS and OBS values are calculated based on a macro variable value that I compute in two prior DATA STEPs using a CALL SYMPUT. I then attempt to pass those values to my macro (which is were I think the breakdown is occuring) which it uses to calcute the FIRSTOBS and OBS values for each iteration of a %DO loop. Inside the loop, I am also opening the ODS buffer to spool off statement to the dynamically named .SAS files mentioned above.

Any ideas on what I am doing wrong?
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggest you share some code and explain exactly what error (or undesirable result) you are getting. When deriving SYMPUT, there are resolution issues that can occur, so you always want to end each DATA (and PROC for my own opinion) with a RUN; statement, so SAS performs the compilation up to the current point in the code execution, even within a macro.

Also, consider writing a general purpose (as in one resuable) macro and re-execute it as needed passing any necessary parameters.

Scott Barry
SBBWorks, Inc.
Michael_W
Fluorite | Level 6
Thanks Scott. Great suggestion. I will definitely keep that in mind down the road. Shortly after posting my issue, I figured out what my problem was (I was using single quotes when I should have used double quotes). That simple oversight ultimately did the trick! Thanks for responding so quickly.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 2 replies
  • 1240 views
  • 0 likes
  • 2 in conversation