To whom it may concern,
I have been using the code below to read the data into SAS from the attached file.
I have observed the following two problems, which I think can be solved with the same solution.
1) My code doesn't seem to load values beyond month30.
2) My code loads a blank value for month18 and then loads incorrect values, which do not correspond to the ones in the attached file.
I know that the solution is simple, however, I can't seem to crack it.
Any help would be extremely appreciated.
data test;
infile '/file location/.txt' dlm='090D'x;
input location :$2 month1-month120;
run;
By current default with an infile statement the expected maximum data line lenght is 255 characters. I think your lines are exceeding that and not reading correctly. Add a LRecL=1500 (or a number at least as large as the number of characters) to the infile statement.
By current default with an infile statement the expected maximum data line lenght is 255 characters. I think your lines are exceeding that and not reading correctly. Add a LRecL=1500 (or a number at least as large as the number of characters) to the infile statement.
ballardw,
Many thanks, this is extemely helpful; one more (minor problem) that arose, however, is this. Although your solution remedied both my problems, I find that the full length of my number isn't being accommodated; for example, I am missing the last 2 decimal digits for each one of my observations (the number I get in the data set is a rounded one) and my Informat doesn't seem to be helping, in addition to returning a blank for my last observation. Below is my new code.
Any thoughts?
data test;
infile '/fmac/users/f371032/HPI.txt' dlm='090D'x LRecL=10000;
input location $2. month1-month120 2.30;
run;
I guess it has to do with the format that is used by default BEST12. for displaying a number.
Add a FORMAT statement to your code like this:
data test;
infile '/folders/myfolders/example.txt' dlm='090D'x LRecL=10000;
input
location : $2.
month1-month120 : 8.
;
format
month1-month120 32.12
;
run;
Thanks!
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.
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.