I have a following dataset with two variables (var, count):
var count
-------------------------- -------
Lassion Good Boy 2
jassion bay boy 5
Pankha 10
How can I create a dataset (not proc report, as I will use the result dataset later) without hardcoding as below (an additional row for the variable var), Result dataset should be as below :
var count
---------------- -------
Lassion Good Boy
Lassion Good Boy 2
jassion bad boy
jassion bad boy 5
Pankha
Pankha 10
Thank you so much
Count should still be numeric.
Thank you
data want(drop=_cnt);
set have(rename=(count=_cnt));
output;
count=_cnt;
output;
run;
Are you familiar with the OUTPUT statement? That should be all you need for this problem. If order matters, you may want a PROC SORT as well.
And CALL MISSING() as well, to set values to missing is a convenient option. It doesn't matter if the variable is character or numeric.
@SAS_Practice wrote:
I have a following dataset with two variables (var, count):
var count
-------------------------- -------
Lassion Good Boy 2
jassion bay boy 5Pankha 10
How can I create a dataset (not proc report, as I will use the result dataset later) without hardcoding as below (an additional row for the variable var), Result dataset should be as below :
var count
---------------- -------
Lassion Good Boy
Lassion Good Boy 2
jassion bad boy
jassion bad boy 5Pankha
Pankha 10
Thank you so much
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.