The enclosed code is not inputting two alphanumeric variables which are in the enclosed txt file. How to read this data in? The software just hangs up and nothing happens? Thanks.
Mary A. Marion
%let dirdata=/folders/myshortcuts/611/data/Week 03/HWdata/;
data names;
infile "&dirdata.top-1000-baby-boy-names.mm.txt"
/* termstr=CRLF */ truncover lrecl=512 pad ;
*input name $ rank2 comma9. @@;
input name: $30. rank2 $ @@;
run;
proc print; run; *963 obs, should be 1000 obs;
data have;
infile 'C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt' lrecl=32767;
input name: $30. rank2 $ @@ ;
run;
1163 data have;
1164 infile 'C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt' lrecl=32767;
1165 input name: $30. rank2 $ @@ ;
1166 run;
NOTE: The infile 'C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt' is:
Filename=C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt,
RECFM=V,LRECL=32767,File Size (bytes)=13220,
Last Modified=30Sep2019:05:45:16,
Create Time=30Sep2019:05:45:16
NOTE: 488 records were read from the infile 'C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt'.
The minimum record length was 8.
The maximum record length was 415.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.HAVE has 1000 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
data have;
infile 'C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt' lrecl=32767;
input name: $30. rank2 $ @@ ;
run;
1163 data have;
1164 infile 'C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt' lrecl=32767;
1165 input name: $30. rank2 $ @@ ;
1166 run;
NOTE: The infile 'C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt' is:
Filename=C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt,
RECFM=V,LRECL=32767,File Size (bytes)=13220,
Last Modified=30Sep2019:05:45:16,
Create Time=30Sep2019:05:45:16
NOTE: 488 records were read from the infile 'C:\Users\sony\Desktop\top-1000-baby-boy-names.mm.txt'.
The minimum record length was 8.
The maximum record length was 415.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.HAVE has 1000 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
@MaryA_Marion wrote:
novinosrin, Thanks. Is there something special about lrecl=32767? I tried using lrecl=512 and got an error. MM
Depends on the error;
Post the code with the error message from the log, Copy from the log and paste into a code box opened with the forum's {I} or "running man" icon.
TRUNCOVER really doesn't make a lot of sense when using the @@ to hold the input line though.
I have to say that whoever compiled that source file has issues though unless there is some information that is important that has been removed. Having from one to thirty or so names on a single row and the names in neither rank order or alphabetical order is pretty odd IMHO.
You cannot use TRUNCOVER option on the INFILE statement in combination with the double trailing @ on INPUT statement.
The former says to stay on the same line after reading past the end of the data on the line. The later says to keep on the same line after the end of the data step iteration. The combination means that it will never read past the first line of the input text.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.