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:
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.