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

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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