BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10

 

using sashelp.class 

i want output as like below

 

 

 

 

ObsNameSexAgeHeightWeight
1AlfredM1469112.5
2AliceF1356.584
3BarbaraF1365.398
4CarolF1462.8102.5
5HenryM1463.5102.5
6JamesM1257.383
7JaneF1259.884.5
8JanetF1562.5112.5
9JeffreyM1362.584
10JohnM125999.5
11JoyceF1151.350.5
12JudyF1464.390
13LouiseF1256.377
14MaryF1566.5112
15PhilipM1672150
16RobertM1264.8128
17RonaldM1567133
18ThomasM1157.585
19WilliamM1566.5112
20Name_Total=19SEX_TOTAL=19Total_age=19Total_height=19Total_weithg=19
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User
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;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User
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;
BrahmanandaRao
Lapis Lazuli | Level 10

Thank You very much

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1509 views
  • 0 likes
  • 2 in conversation