What is the difference between these two txt file? I am unable to read the second one.
They seems to have the same free style format and embedded blank.
1) data file
my code: I am able to run this one.
data shortnamesds;
infile ' /home/coccus030/sasuser.v94/nfldata2.txt' firstobs=2;
*/ @20 to indicate SAS to read at 20 city and year are too close to each other;
input City & $16. @20 Year Team $;
run;
----+----1----+----2----+----3
Baltimore 2012 Ravens
Cincinnati 2012 Bengals
Cleveland 2012 Browns
Pittsburgh 2012 Steelers
Chicago 2012 Bears
2) data file
Bellfort Yes No Yes Yes Yes Yes Yes Yes yes
North Carolina Yes No Yes Yes Yes Yes Yes Yes yes
South Raleigh Yes No Yes Yes Yes Yes Yes Yes yes
My code: Unable to run
data answer;
infile '/home/coccus030/sasuser.v94/audit.txt';
input State & $16. @17 Q1 $ Q2 $ Q3 $ Q4 $ Q5 $ Q6 $ Q7 $ Q8 $ Q9 $;
run;
Thx
Did you properly account for the two words in the second data set with the double space?
If you post your code in the HTML editor vs a code box there's no way to verify that, so you need to ensure it is in SAS or the text file.
@elsalam wrote:
What is the difference between these two txt file? I am unable to read the second one.
They seems to have the same free style format and embedded blank.
1) data file
my code: I am able to run this one.
data shortnamesds;
infile ' /home/coccus030/sasuser.v94/nfldata2.txt' firstobs=2;
*/ @20 to indicate SAS to read at 20 city and year are too close to each other;
input City & $16. @20 Year Team $;run;
----+----1----+----2----+----3
Baltimore 2012 Ravens
Cincinnati 2012 Bengals
Cleveland 2012 Browns
Pittsburgh 2012 Steelers
Chicago 2012 Bears
2) data file
Bellfort Yes No Yes Yes Yes Yes Yes Yes yes
North Carolina Yes No Yes Yes Yes Yes Yes Yes yes
South Raleigh Yes No Yes Yes Yes Yes Yes Yes yes
My code: Unable to run
data answer;
infile '/home/coccus030/sasuser.v94/audit.txt';input State & $16. @17 Q1 $ Q2 $ Q3 $ Q4 $ Q5 $ Q6 $ Q7 $ Q8 $ Q9 $;
run;
Thx
I was able to read the data but not at the right position.
See attached.
You are using & within the INPUT statement, without understanding what it means. Take a look, this should clear it up:
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.