using sashelp.class
i want output as like below
Obs | Name | Sex | Age | Height | Weight |
1 | Alfred | M | 14 | 69 | 112.5 |
2 | Alice | F | 13 | 56.5 | 84 |
3 | Barbara | F | 13 | 65.3 | 98 |
4 | Carol | F | 14 | 62.8 | 102.5 |
5 | Henry | M | 14 | 63.5 | 102.5 |
6 | James | M | 12 | 57.3 | 83 |
7 | Jane | F | 12 | 59.8 | 84.5 |
8 | Janet | F | 15 | 62.5 | 112.5 |
9 | Jeffrey | M | 13 | 62.5 | 84 |
10 | John | M | 12 | 59 | 99.5 |
11 | Joyce | F | 11 | 51.3 | 50.5 |
12 | Judy | F | 14 | 64.3 | 90 |
13 | Louise | F | 12 | 56.3 | 77 |
14 | Mary | F | 15 | 66.5 | 112 |
15 | Philip | M | 16 | 72 | 150 |
16 | Robert | M | 12 | 64.8 | 128 |
17 | Ronald | M | 15 | 67 | 133 |
18 | Thomas | M | 11 | 57.5 | 85 |
19 | William | M | 15 | 66.5 | 112 |
20 | Name_Total=19 | SEX_TOTAL=19 | Total_age=19 | Total_height=19 | Total_weithg=19 |
proc sql;
select
name,
sex,
put(age,15.) as age,
put(height,15.) as height,
put(weight,15.1) as weight
from sashelp.class
union all
select
catx(' ','Total',strip(put(count(name),2.))) as name,
catx(' ','Total',strip(put(count(sex),2.))) as sex,
catx(' ','Total',strip(put(count(age),2.))) as age,
catx(' ','Total',strip(put(count(height),2.))) as height,
catx(' ','Total',strip(put(count(weight),2.))) as weight
from sashelp.class;
quit;
proc sql;
select
name,
sex,
put(age,15.) as age,
put(height,15.) as height,
put(weight,15.1) as weight
from sashelp.class
union all
select
catx(' ','Total',strip(put(count(name),2.))) as name,
catx(' ','Total',strip(put(count(sex),2.))) as sex,
catx(' ','Total',strip(put(count(age),2.))) as age,
catx(' ','Total',strip(put(count(height),2.))) as height,
catx(' ','Total',strip(put(count(weight),2.))) as weight
from sashelp.class;
quit;
Thank You very much
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.