BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RobertHuey
Calcite | Level 5

Hi all,

Is there a way to keep my PROC IMPORT procedure from truncating my unique identifier?  It is about 20 numbers long and is converted to scientific notation using my procedure.  It uses the best12 format and I'm importing from a txt delimited file with vertical bars as the delimeter.  The last two digits are what make these identifiers unique and I need them, not the scientific notation.

Thanks for any help!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

20 digits are too many for a number.  SAS stores numbers as 8 bytes floating point and so only has 17 digits of precision.

It is probably better to read the file using a data step instead of using PROC IMPORT.  PROC IMPORT will have to guess as to the data types for your variables.

data mydata ;

   infile 'mydata.txt' dsd dlm='|' lrecl=32000 truncover firstobs=2;

   length ID $20 ..... ;

   input ID .... ;

run;

Fill in the names for the rest of your variables.  For date and time variables add INFORMAT and FORMAT statements.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

20 digits are too many for a number.  SAS stores numbers as 8 bytes floating point and so only has 17 digits of precision.

It is probably better to read the file using a data step instead of using PROC IMPORT.  PROC IMPORT will have to guess as to the data types for your variables.

data mydata ;

   infile 'mydata.txt' dsd dlm='|' lrecl=32000 truncover firstobs=2;

   length ID $20 ..... ;

   input ID .... ;

run;

Fill in the names for the rest of your variables.  For date and time variables add INFORMAT and FORMAT statements.

ballardw
Super User

Proc import generated a SAS datastep program similar to Tom's stub. It would be in the log. You can either copy the text from the log or use F4 key to Recall the program text into the editor.

Modify the code as Tom suggested, looking at other variables as well. If this going to me done more than once take a good look at any variables, especially character to consider making them longer as the next iteration of the data may be longer.

Consider specifying better variable names, especially if you get varxx type name, and adding meaningful labels for the variables.

Save the code and you'll be ready to go next by changing the infile information and possibly the output data set name.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3807 views
  • 3 likes
  • 3 in conversation