BookmarkSubscribeRSS Feed
NadiaK
Fluorite | Level 6

Hello all!

 

I am new to sas and I am stumped with one of my numeric variables.

 

So, I have a variable name 'sampleid' which is 14 digits long- no space or dots or commas. When I imported my csv file to sas the sampleid of 020613020202021 looks like this: 2.02E+12. Can anyone help with that?

 

Thanks!

3 REPLIES 3
ballardw
Super User

Proc Import in addition to guessing variable types defaults to a "best" format for non-date or time variables.

You can get more digits displayed by assigning a format with more allowed digits such as best14. or F14.

 

Note that your variable is being treated as numeric so your leading zeroes would require a Z14. format to show them.

 

You can change the format a number of ways. Best is at reading.

 

Data mytable;

   set mytable;

   format sampleid z14.;

run;

is inefficient but simple. Proc datasets can modify formats of variables in place. Or the point-and-click on the table column header should allow setting the format.

NadiaK
Fluorite | Level 6
Thank you thank you thank you 😄
It worked!!!
Tom
Super User Tom
Super User

If it is really an ID then you probably will want to read it as character instead of reading it as a number. 14 digits is close to the maximum integer that SAS can store uniquely in a numeric variable.

23    data _null_;
24      x=constant('exactint');
25      put x= comma24. ;
26    run;

x=9,007,199,254,740,992

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
  • 452 views
  • 0 likes
  • 3 in conversation