data hpi;
infile "/file_location/InterestRates.txt";
input var1-var1000;
run;
proc print data=hpi;
run;
I have the code posted in addition to the attached data. I am trying to import my data into SAS while avoiding the severe truncation that seems to be going on. Could someone please help?
Thank you.
You have not defined any format to your variables.
The data is probably not truncated but in your report.
Add a format like:
data hpi;
infile "/file_location/InterestRates.txt";
input var1-var1000;
format var1-var1000 18.16 ;
run;
proc print data=hpi;
run;
You may need add the format statemnt, same or diffrent in the proc print.
Format 18.16 defines total display length is 18 caharacters with 16 decimal digits.
You have not defined any format to your variables.
The data is probably not truncated but in your report.
Add a format like:
data hpi;
infile "/file_location/InterestRates.txt";
input var1-var1000;
format var1-var1000 18.16 ;
run;
proc print data=hpi;
run;
You may need add the format statemnt, same or diffrent in the proc print.
Format 18.16 defines total display length is 18 caharacters with 16 decimal digits.
You have two issues here. One you can fix and the other you cannot.
First the default format that is used to display numbers is BEST12., you can use other formats for displaying numbers.
Second SAS using 64 bit IEEE floating point format to store numbers. There is limit on the number of digits of precision that can be stored and many of the values in your text file exceed that limit. But it most likley will not any real impact on using the data.
Here is example of one of the values in your text file that has too many digits to store precisely.
data test;
input x 20.;
put _infile_ / x / x 20.18 ;
cards;
0.021082546905855537
;
0.021082546905855537 0.0210825469 0.021082546905855500
Looks like your source data doesn't have any end-of-line indicators but is a single stream of data. RECFM=N can deal with that.
As @Tom writes: SAS can only hold numerical values up to a length of 16 digits with full precision. If that's good enough then below should work; else read the digits into a character variable of sufficient length - but then you can't use it for calculations in a normal SAS data step.
data sample;
infile "C:\temp\InterestRates.txt" dlm=' ' recfm=n;
/* input c_var:$20. ;*/
input n_var:best32.;
run;
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 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.