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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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