Help using Base SAS procedures

help with infile

Reply
N/A
Posts: 0

help with infile

When I try to import the data below, I keep having problems with the last variable VARc
if I specify that the lenght is 3, it only takes the variables that have three digits, if i put 2 it omits the third digit.....any help, Thanks
If I use the wizard import it magically creates a 6th variable with . in them???

(Note: I am a new SAS user. )

here is my code:

data ANY;
infile "E:\ANY.txt" ;
input @1 Date $8. @10 name $5. @16 VARa 3. @20 VARb 3. @24 VARc 2.;
run;

content of the text file

02-02-93 Jason 306 145 97
02-02-93 John 212 132 85
02-09-93 John 215 129 89
02-09-93 Jason 295 142 85
02-09-93 Mary 303 150 102
02-09-93 Beth 323 145 97
02-16-93 Beth 320 149 104
02-16-93 Jason 285 140 87
02-16-93 Mary 999 145 97
02-16-93 John 220 135 93
02-23-93 Mary 307 149 99
02-23-93 John 215 133 92
02-23-93 Beth 319 143 99
Respected Advisor
Posts: 3,777

Re: help with infile

I expect you see this message.
[pre]
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
[/pre]

To fix it use INFILE option TRUNCOVER.

Or switch to list input...

[pre]
filename FT15F001 temp;
data ANY;
*infile "E:\ANY.txt" ;
Infile FT15F001 truncover;
input (Date name VARa VARb VARc)(:mmddyy8. :$5. 3*:3.);
parmcards;
02-02-93 Jason 306 145 97
02-02-93 John 212 132 85
02-09-93 John 215 129 89
02-09-93 Jason 295 142 85
02-09-93 Mary 303 150 102
02-09-93 Beth 323 145 97
02-16-93 Beth 320 149 104
02-16-93 Jason 285 140 87
02-16-93 Mary 999 145 97
02-16-93 John 220 135 93
02-23-93 Mary 307 149 99
02-23-93 John 215 133 92
02-23-93 Beth 319 143 99
;;;;
run;
proc print;
run;
[/pre]
N/A
Posts: 0

Re: help with infile

I added the word truncover and it worked.
Thank you so much! I was going nuts.
Ask a Question
Discussion stats
  • 2 replies
  • 113 views
  • 0 likes
  • 2 in conversation