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!
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.
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.