BookmarkSubscribeRSS Feed
Gfish
Fluorite | Level 6

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.

4 REPLIES 4
art297
Opal | Level 21

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.

Gfish
Fluorite | Level 6

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

ballardw
Super User

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;

Gfish
Fluorite | Level 6

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!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 929 views
  • 3 likes
  • 3 in conversation