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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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