Hello Friends
Can you please help me on this query?
I want to get out put for the following file using list or modified list input.
2458 Murray, W 72 185 128 12 38 D
2462 Almers, C 68 171 133 10 5 I
2501 Bonaventure, T 78 177 139 11 13 I
2523 Johnson, R 69 162 114 9 42 S
2539 LaMance, K 75 168 141 11 46 D
Thanks.
Not sure what you're asking, but the following might be close to what you're looking for:
data want (drop=x); infile cards truncover; informat name $20.; input @; x=anydigit(substr(_infile_,5))+4; _infile_=substr(_infile_,1, x-1)||' '||substr(_infile_,x); input id name & x1-x5 z $; cards; 2458 Murray, W 72 185 128 12 38 D 2462 Almers, C 68 171 133 10 5 I 2501 Bonaventure, T 78 177 139 11 13 I 2523 Johnson, R 69 162 114 9 42 S 2539 LaMance, K 75 168 141 11 46 D ;
Art, CEO, AnalystFinder.com
Thanks for your reply.
I need to get out as eg, Murray, W in the output.
That's what the code I suggested does.
Art, CEO, AnalystFinder.com
Thanks Art for your help and appreciate that, let me try how it work.
Simplest might be to read in the first initial as a separate variable, then tack it on to the last name. For example:
data want;
length lastname $ 15;
input id lastname initial $ n1 n2 n3 n4 n5 c1 $;
name = catx(' ', lastname, initial);
drop lastname initial;
cards;
2458 Murray, W 72 185 128 12 38 D
2462 Almers, C 68 171 133 10 5 I
2501 Bonaventure, T 78 177 139 11 13 I
2523 Johnson, R 69 162 114 9 42 S
2539 LaMance, K 75 168 141 11 46 D
;
Thanks and appreciated for your help.
This is what I get.
My code:
data want;
length lastname $15.;
input
id lastname initial $ RestHR MaxHR RecHR TimeMin TimeSec Tolerance $;
name = catx('',lastname, initial);
drop lastname initial;
cards;
2458 Murray, W 72 185 128 12 38 D
2462 Almers, C 68 171 133 10 5 I
2501 Bonaventure, T 78 177 139 11 13 I
2523 Johnson, R 69 162 114 9 42 S
2539 LaMance, K 75 168 141 11 46 D
;
run;
proc print;run;
Here is the output:
How can I get name in the first column after obs?
What is the importance of this line
drop lastname initial;
Thanks.
To get NAME in the first column, add it to the LENGTH statement. For example:
length name $ 20 lastname $ 15;
A DROP statement you will need to learn, as part of the basics. It means that the variables LASTNAME and INITIAL should not become part of the final data set. They are computed along the way, but should be removed.
Great. It works fine.
Thanks lot.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: