Hello SAS Community,
I have a macro list that contains 14-digit numeric IDs. When I %put the list in the log I am not seeing the 14-digits, but rather:
NOTE: There were 29 observations read from the data set WORK.BIH.
WHERE MemID not in (1.9961106E13, 1.9961109E13, 1.9961109E13, 1.9961109E13, 1.9961109E13, 1.9961109E13, 1.9961109E13,1.9961109E13, 1.9961109E13, 1.9961109E13, 1.9961109E13, 1.996111E13, 1.996111E13, 1.996111E13, 1.996111E13, 1.996111E13,1.9961111E13,1.9961203E13, 1.9961203E13, 1.9961203E13, 1.9961203E13, 1.9961203E13, 1.9961203E13, 1.9961203E13, 1.9961203E13, 1.9961204E13...);
Can anyone advise why SAS is converting the ID to this format? I need to keep the 14 digit format in the macro list for further linking. Thanks!
The problem occurred earlier, when creating the macro variable. You have to go back to that section of code to fix it.
Most likely, you had something like this:
proc sql;
select distinct id into : my_macrovar separated by ', ' from source_data;
quit;
Since macro variables are character strings, and ID is numeric, this forces SQL to make a numeric to character conversion. And SQL uses a 12-character format when doing that. You can control the process by changing the SELECT statement:
select distinct put(id, 14.) into : my_macrovar separated by ', ' from source_data;
The problem occurred earlier, when creating the macro variable. You have to go back to that section of code to fix it.
Most likely, you had something like this:
proc sql;
select distinct id into : my_macrovar separated by ', ' from source_data;
quit;
Since macro variables are character strings, and ID is numeric, this forces SQL to make a numeric to character conversion. And SQL uses a 12-character format when doing that. You can control the process by changing the SELECT statement:
select distinct put(id, 14.) into : my_macrovar separated by ', ' from source_data;
Thank you so much for the swift response! This is the perfect solution for my issue. The previous format was 12-digit, so I never had a problem before. Thanks again!
Since the variable has a name MEMID I am guessing it is some sort of an identifier. If so you should likely make it character and long enough to hold any expected growth 16 or 20 characters since most organizations do very little arithmetic with member identifiers. Then this issue would never arise and not run into potential issues with the precision of storage.
Example:
data junk; x = 12345678912345678; y = 12345678912345679; run; proc print data=junk; format x y best32.; run;
with a result of
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.
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.