Help using Base SAS procedures

Import text file

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 75
Accepted Solution

Import text file

Hallo, I have some text files and I would like to import them in sas. But I only get one column instead of different column. Can someone please help me with this? I attach the text file here. Thanks.

Attachment

Accepted Solutions
Solution
‎11-30-2012 10:49 AM
Respected Advisor
Posts: 4,932

Re: Import text file

Assuming you only want the first portion of the file :

filename myFile "&sasforum.\datasets\F-F_Research_Data_Factors.txt";

data test;
format dt yymmn6.;
label Mkt_RF="Mkt-RF";
infile myFile missover;
input @;
if anyalpha(_infile_) = 0 and length(trimn(_infile_)) > 0 then do;
     input dttxt $ Mkt_RF SMB HML RF;
     if length(trim(dttxt)) = 6 then do;
          dt = input(dttxt, yymmn6.);
          output;
          end;
     end;
drop dttxt;
run;

PG

PG

View solution in original post


All Replies
Solution
‎11-30-2012 10:49 AM
Respected Advisor
Posts: 4,932

Re: Import text file

Assuming you only want the first portion of the file :

filename myFile "&sasforum.\datasets\F-F_Research_Data_Factors.txt";

data test;
format dt yymmn6.;
label Mkt_RF="Mkt-RF";
infile myFile missover;
input @;
if anyalpha(_infile_) = 0 and length(trimn(_infile_)) > 0 then do;
     input dttxt $ Mkt_RF SMB HML RF;
     if length(trim(dttxt)) = 6 then do;
          dt = input(dttxt, yymmn6.);
          output;
          end;
     end;
drop dttxt;
run;

PG

PG
Frequent Contributor
Posts: 75

Re: Import text file

Thank you!!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 210 views
  • 0 likes
  • 2 in conversation