how to read in variables with trailing blanks

Reply
Occasional Contributor
Posts: 8

how to read in variables with trailing blanks

Hi,

I have a output file (.txt) that I would like to read in to SAS. The delimiter used in the file is blank. I want to read every row (where some variables start from the very first column while the others have trailing blanks in front of them). Is there a way that I can read every thing (all the variables including the ones after the trailing blanks) into SAS as one variable? I tried using semi colon with keyword, using @ to change the point, and some other ways and none of them worked. The output is attached. I would like to read in the row stating the warning message after the line "THE MODEL ESTIMATION TERMINATED NORMALLY".

Any help is appreciated.

Attachment
PROC Star
Posts: 7,364

Re: how to read in variables with trailing blanks

I think you will have to provide the forum with at least a small subset of the data you are trying to read, as well as what you expect from that data as a result.

Occasional Contributor
Posts: 8

Re: how to read in variables with trailing blanks

Thank you for the suggestion. I uploaded the output file.

Super User
Posts: 10,538

Re: how to read in variables with trailing blanks

I think you meant Leading blanks.

And do you want all of the data in a single variable containing the whole row of data? Something like

Var = '     123     12341234123412341234      09808   adrasf'

Then a data step does that easily enough

data want;

     infile "your file name" LRECL=32000; /* or length of longest line*/

     input var $varying32000. ; /* again length of longest line*/

run;

Occasional Contributor
Posts: 8

Re: how to read in variables with trailing blanks

sorry. My mistake. I did mean leading blanks. I tried the code and it works after I added the length of the variable after $varying informat. Thanks a lot!

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