BookmarkSubscribeRSS Feed
pawandh
Fluorite | Level 6

%let a=2 here a is a macro variable and is character and if i write ths

proc print data=data;

where rating=&a;

run;

then records with rating=2 is coming.How ths character is getting resolved as numeric over here?

2 REPLIES 2
mohamed_zaki
Barite | Level 11

"Macro variables contain only character data. However, the macro facility has features that enable a variable to be evaluated as a number when it contains character data that can be interpreted as a number."

 

 

Introduction to Macro Variables

Astounding
PROC Star

SAS language can interpret 2 as either character or numeric, depending on the context:

 

xrays=2;

robot='R2D2';

 

Macro language is not determining whether "2" is character or numeric.  It is merely substituting "2" into the program, making it:

 

proc print data=data;

where rating=2;

run;

 

SAS language then interprets the program, and decides what each word means.  

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