04-23-2017 10:01 AM
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
04-24-2017 04:59 AM
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);
04-23-2017 10:20 AM - edited 04-23-2017 10:21 AM
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 ;