BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sg_kr
Obsidian | Level 7

Hi ,

 

i have to read an unstructured data from a text file to SAS dataset 

 

raw data like below:

Description AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
assakndsklfdsfpsdskmcs'kfdskfnsd'vkmsdv;ls vlksnfdks'fjdsoifnsonvs;lnsohfsnskjfhso;fskfjslfks';fljslkfjs;lfjslkfj;lksfjslkfjos;kufoeisocnds;ojvnoriecnwiocns
fhdsiupfhwfnsdpcmdwpofwecmsd'lkvnpsfmspcns[oijsncspncdsvnsnccd
 
 
accountno  date current_balance credit debit total_bal
*********************************************************
1111 01/02/2000 100 20 40 80
 
2222 01/02/2000 10 20 30 0
2222 02/02/2000 40 10 2 48
 
 
accountno  date current_balance credit debit total_bal
*********************************************************
1111 01/02/2000 100 20 40 80
 
2222 01/02/2000 10 20 30 0
222202/02/20004010248
 
 
accountno  date current_balance credit debit total_bal
*********************************************************
1111 01/02/2000 100 20 40 80
 
2222 01/02/2000 10 20 30 0
222202/02/20004010248
 
accountno  date current_balance credit debit total_bal
*********************************************************
1111 01/02/2000 100 20 40 80
 
2222 01/02/2000 10 20 30 0
222202/02/20004010248
 
Output---
i want dataset to be with the following columns
accountno  date current_balance credit debit total_bal
 
kindly please help us on this
 
 
also i have attached the file as well
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
filename x 'c:\temp\test.txt' encoding='utf8' termstr=crlf;
data have;
infile x  dlm='09'x dsd;
input @;
if anydigit(_infile_) ne 1 then delete;
input (accountno  date current_balance credit debit total_bal) (: $40.);
run;

View solution in original post

3 REPLIES 3
Ksharp
Super User
filename x 'c:\temp\test.txt' encoding='utf8' termstr=crlf;
data have;
infile x  dlm='09'x dsd;
input @;
if anydigit(_infile_) ne 1 then delete;
input (accountno  date current_balance credit debit total_bal) (: $40.);
run;
sg_kr
Obsidian | Level 7
thanks for the response, just want to know about the two input statements in the data step.

and how to deal if my columns names are two words like account no, instead of accountno
Ksharp
Super User
/*OK. Using liternal name syntax.*/

option validvarname=any;  *Make sure variable name could contain blanks;
filename x 'c:\temp\test.txt' encoding='utf8' termstr=crlf;
data have;
infile x  dlm='09'x dsd;
input @;
if anydigit(_infile_) ne 1 then delete;
input ('account no'n  date current_balance credit debit total_bal) (: $40.);
run;

sas-innovate-white.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.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 954 views
  • 2 likes
  • 2 in conversation