Help using Base SAS procedures

Help needed! Having trouble in reading varying number of repeated fields (character variable)

Reply
N/A
Posts: 1

Help needed! Having trouble in reading varying number of repeated fields (character variable)

1.png

Here it is my data file.

And I run the following code

data work.final;

   infile temp1 missover;

   input date nasins $ @;

   count=0;

   do while (nasins ne ' ');

   count+1;

   output;

   input nasins $ @;

   end;

run;

proc print data=work.final;

run;

The log shows the following

870  data work.final;

871     infile temp1 missover;

872     input date nasins $ @;

873     count=0;

874     do while (nasins ne ' ');

875     count+1;

876     output;

877     input nasins $ @;

878     end;

879  run;

ERROR: No logical assign for filename TEMP1.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.FINAL may be incomplete.  When this step was stopped there were 0

         observations and 3 variables.

WARNING: Data set WORK.FINAL was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

880  proc print data=work.final;

881  run;

NOTE: No observations in data set WORK.FINAL.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

Can anyone provide some solutions?

Thans!

SAS Employee
Posts: 967

Re: Help needed! Having trouble in reading varying number of repeated fields (character variable)

Here is one brute-force way to do what you're wanting...

 

data final (keep = date nasins);
input whole_line $ 1-80;
date=.; date=scan(whole_line,1,' ');
do i = 2 to countw(whole_line);
 nasins=scan(whole_line,i,' '); 
 output;
 end;
datalines;
1386036001 B002OO333Q B004M6XUI2 B006232JFS B00B1D03GQ B00CAKA062
1386036002 B00C6TZON6
1386036003 B001R4BT1M B00C43H85G B00DOSAMMQ B00EV207NS
;
run;

proc print data=final; 
run;
Super User
Posts: 17,750

Re: Help needed! Having trouble in reading varying number of repeated fields (character variable)

Is that already a SAS data set or a text file your trying to read?
Super User
Super User
Posts: 6,497

Re: Help needed! Having trouble in reading varying number of repeated fields (character variable)

Did you read the error message that you posted?

ERROR: No logical assign for filename TEMP1.

That means that there is no FILENAME statement defining what actual file TEMP1 is supposed to reference.

You can use either a libref or a quoted physical filename on the INFILE statement.

 

Ask a Question
Discussion stats
  • 3 replies
  • 261 views
  • 0 likes
  • 4 in conversation