BookmarkSubscribeRSS Feed
telescopic
Calcite | Level 5

Hi, I am trying to use macro to produce automatically sasdata set under name: file1,file2,...file5 each which will contain a time series. The following code does't produce those 5 sets. Can someone suggest a solution? 

Thank you

---------------------------------

%MACRO TS;

%DO I=1 %TO 5;

     Data file||&I;

     w=0;

     DO t=0 to 100;

     money=rannor(0);

     w=money+w;

     x=0.3*t+w;

     output;

     END;

     RUN;

%END;

%MEND TS;

%TS;

1 REPLY 1
Ksharp
Super User

You do not need || for macro variable.

%DO I=1 %TO 5;

     Data file&I;

Ksharp

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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
  • 1 reply
  • 803 views
  • 0 likes
  • 2 in conversation