BookmarkSubscribeRSS Feed
bogapraveen
Calcite | Level 5

Hi,

 

Please let me know how to read the attached data in the proper way.

please give the code.

 

Thank you,

 

Regards,

Praveen

 

3 REPLIES 3
art297
Opal | Level 21

I don't think there is one "proper" way. Here is one way that would work:

 

data  want (drop=_:);
  infile 'c:\art\ds.txt' firstobs=6;
  informat name $40.;
  input @;
  call scan(_infile_,-1,_position,_length);
  month=substr(_infile_,_position);
  _infile_=substr(_infile_,1,_position-1);
  input sales orderno name &;
run;

Art, CEO, AnalystFinder.com

 

bogapraveen
Calcite | Level 5

Thank you for your reply, I am getting output what I expected.

Is there any shortcut code apart from this line, using  : @ type of input statements.

 

I am sorry, I could understand the following line. 

 

input @;
  call scan(_infile_,-1,_position,_length);
  month=substr(_infile_,_position);
  _infile_=substr(_infile_,1,_position-1);

 Thank you,

 

Regards,

Praveen

 

 

 

 

 

Regards,

Praveen

Tom
Super User Tom
Super User

Depends on what you want. If you want to read them all into a single row then just read them all as names and move the last one into the month field.

data want;
  infile datalines truncover  ;
  length sales orderno 8 month $3 num 8;
  array name (10) $28 ;
  input sales orderno name1-name10 ;
  num =  dim(name) - cmiss(of name(*));
  month = name(num);
  name(num)=' ';
  num=num-1;
  format sales dollar9.;
datalines;
25000 2 raheem pasha shaik jan
30000 3 shaik shabeer pasha aug
45000 6 rama krishna oct
98000 5 gopal feb
;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1583 views
  • 0 likes
  • 3 in conversation