BookmarkSubscribeRSS Feed
itemsong
Calcite | Level 5

%macro test(x);

data temp;

     set temp1;

     y=5;

     y = y + &x.;

run;

%mend;

%test(5);

will y be equal to 10?

3 REPLIES 3
Sudhakar_A
Calcite | Level 5

%macro test(x);

data temp;

     y=5;

     y = y + &x.;

run;

%mend;

%test(5);

Yes it will be 10, check this code.

ballardw
Super User

You may be looking for SYMGET as well if the application is more complex then your example.

Tom
Super User Tom
Super User

Yes. For every observation read from TEMP1 and written to TEMP will have Y=10.

You can try it without the macro wrapper by just using %LET to set the value of the macro variable X.

%let x=5;

data temp;

   set sashelp.class ;

   y=5 + &x ;

   put (name y) (=);

run;

Name=Alfred y=10

Name=Alice y=10

Name=Barbara y=10

Name=Carol y=10

Name=Henry y=10

Name=James y=10

Name=Jane y=10

Name=Janet y=10

Name=Jeffrey y=10

Name=John y=10

Name=Joyce y=10

Name=Judy y=10

Name=Louise y=10

Name=Mary y=10

Name=Philip y=10

Name=Robert y=10

Name=Ronald y=10

Name=Thomas y=10

Name=William y=10

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 885 views
  • 0 likes
  • 4 in conversation