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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 784 views
  • 0 likes
  • 3 in conversation