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
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.