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

Dear SAS community,

 

I wish to import data sets for circa 60 .txt. files to SAS. Each file's data set consists of a single line of the letters and numbers 123RW in some combination. Due to the length of the data set, it is divided into two lines.

 

Attached are three examples of the data sets in the files I am working with. 

 

I wish to have the data transposed into a single column with the variable name "stages".

 

I also wish to retain the file name of the individual files and insert it as a variable in each file. Thus, for each observation in the data set variable "stages", it should be labeled with the file name (e.g., "ID") in an adjacent column.

 

I am using version 9.4 SAS

 

I have looked online and have made some attempts (see script below), but I have not been successful. Can you please offer me any help or advice?

 

Sincerely,

 

Ian

 


data WANT;
infile 'C:\*.txt' dlm='09'x dsd truncover;

input @@;
run;

1 ACCEPTED SOLUTION
4 REPLIES 4
USCSS_Nostromo
Calcite | Level 5

Hi Kurt Bremser,

 

Thanks for your reply. Single characters. Each observation should be a single character.

-Ian

USCSS_Nostromo
Calcite | Level 5

Hi Kurt Bremser,

 

Thank you yet again. I can't tell you how much I appreciate your help!

 

Best,

 

Ian

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1290 views
  • 0 likes
  • 2 in conversation