I’ve a text file that Im reading in SAS and for some reason the last column (Year_2013) in the file is not populated (blank). I tried to format but it's not taking. The file consists 4 columns. id_cust has character rows and all Year columns has dollar rows. Here’s my SAS code. Any help is appreciated.
data work.rev;
INFILE "/vendorlst.txt"
DELIMITER='09'x
MISSOVER
DSD
LRECL=32767
FIRSTOBS=2;
LENGTH
id_cust $200;
INPUT
Vndr_id_cust $
Year_2011
Year_2012
Year_2013;
RUN;
Your example is space not tab delimited. If that is what your data really look like, the following changes would do what you want. While I changed missover to truncover, that decision will really depend on what your data really look like.
data work.rev;
INFILE "/vendorlst.txt"
truncOVER
LRECL=32767
FIRSTOBS=2;
length
id_cust $200;
INPUT id_cust &
Year_2011
Year_2012
Year_2013;
RUN;
Can you provide a sample of your dataset say, e.g., maybe the first 5 or 10 rows?
One problem is that you define a length for a variable (id_cust), but never use it, but use vndr_id_cust instead.
Thanks, Arthur. To correct on my previous post due typo error. id_cust is same as Vndr_id_cust.
Here’s an example of the Input file in txt file I'm using
Vndr_id_cust Year_2011 Year_2012 Year_2013
ABC CORPORATION 85032386.25 123252387.54 110031088.50
SAS output Result
Your example is space not tab delimited. If that is what your data really look like, the following changes would do what you want. While I changed missover to truncover, that decision will really depend on what your data really look like.
data work.rev;
INFILE "/vendorlst.txt"
truncOVER
LRECL=32767
FIRSTOBS=2;
length
id_cust $200;
INPUT id_cust &
Year_2011
Year_2012
Year_2013;
RUN;
Thanks a lot, Arthur! That solved my issues. There's a column in the file that I would like to break it as follows.
Now, the file has Vndr_id_cust column and I would like the vndr_id and cust to be seperated in two columns (e.g: vndr_id and Cust). Any help is appreciated.
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.
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.