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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
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.
Ready to level-up your skills? Choose your own adventure.