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
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;
By choosing the correct delimiter. Is it a TAB or 1 to n blanks? Are you using a data step or Proc Import?
I think this is 1 to n blanks. Using both data step and proc import shows all variables in one column.
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;
Now it works. Thanks a lot to Tom, Reeza and Patrick.
What does your code look like?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.