BookmarkSubscribeRSS Feed
mgorripati
Obsidian | Level 7

This may be simple or may not be simple .

 

%let ID=1000 ; 

 

PROC SQL;

SELECT * FROM  TABLE WHERE FORMULARY_ID = INPUT(&ID. ,8.);

QUIT;

 

the conversion is not working. 

 

in the TABLE  the FORMULARY_ID is a Number  , how can i  convert Macro variable to number ?

 

any help would be highly appreciated.

 

Thanks,

M

3 REPLIES 3
sh0e
Obsidian | Level 7

The INPUT function is expecting a string. So, try this:

 

%let ID=1000 ; 
 
PROC SQL;
SELECT * FROM  TABLE WHERE FORMULARY_ID = INPUT("&ID". ,8.);
QUIT;

Of course, you don't need to do that. This should work as well.

%let ID=1000 ; 
 
PROC SQL;
SELECT * FROM  TABLE WHERE FORMULARY_ID = &ID.;
QUIT;

HTH

mgorripati
Obsidian | Level 7

Thanks HTH,

 

INPUT("&ID".,8.) has worked.

 

Astounding
PROC Star

When a macro variable gets passed to a SAS program, it is up to the SAS program to determine whether the value is character or numeric.  You could simply use:

 

where formulary_id=&id.;

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
  • 27169 views
  • 1 like
  • 3 in conversation