BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AbuChowdhury
Fluorite | Level 6

Hi Experts,

My text files looks the following. When I am importing this file to SAS, then SAS file shows all variables in one column. How can I solve this?

PERMNO            DATE       CRSP     Return

10001                20040416   20839    -0.003487

10001                20040419   20840     0.051085

10001                20040420   20841    -0.087883

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

If your file is that simple then just write the data step to read.  If you use an importing tool it will have to guess at what variable types to use.

data want ;

   infile 'myfile' firstobs=2 truncover ;

  input PERMNO DATE CRSP Return;

  informat date yymmdd8.;

  format date yymmddN8. ;

run;

View solution in original post

5 REPLIES 5
Patrick
Opal | Level 21

By choosing the correct delimiter. Is it a TAB or 1 to n blanks? Are you using a data step or Proc Import?

Base SAS(R) 9.4 Procedures Guide, Third Edition

AbuChowdhury
Fluorite | Level 6

I think this is 1 to n blanks. Using both data step and proc import shows all variables in one column.

Tom
Super User Tom
Super User

If your file is that simple then just write the data step to read.  If you use an importing tool it will have to guess at what variable types to use.

data want ;

   infile 'myfile' firstobs=2 truncover ;

  input PERMNO DATE CRSP Return;

  informat date yymmdd8.;

  format date yymmddN8. ;

run;

AbuChowdhury
Fluorite | Level 6

Now it works. Thanks a lot to Tom, Reeza and Patrick.

Reeza
Super User

What does your code look like?

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
  • 5 replies
  • 793 views
  • 0 likes
  • 4 in conversation