BookmarkSubscribeRSS Feed
Ashwini
Calcite | Level 5

I have a data set like below mention table

strollstidstnamemathsciencehistorygeographytotalclassgrade
111s111AA60504560215IB
212s212BB70503060210IIB
324S324CC70805070270IIIA
456S456DD60706060250IVA
578S578EE70303060190VC
678S678FF40604040180VIB
789S789CC60405070220VIIB
987S987GG80304050200IXA

I want to create a cross table using above data as below mention table like

student name verses total mark percentage
strollstid mathsciencehistorygeographyAABBCCDDEEFFGGtotalclassgrade

Please help me to solve this ASAP.

Thanks and Regards,

Ashwini

4 REPLIES 4
Tom
Super User Tom
Super User

Can you describe what you want?

Do you just want to transpose the data? Or are you trying to summarize it in some way?

Ashwini
Calcite | Level 5

Dear Tom,

I want a summarized data .

I want to create a cross table contain as below mention table .I want percentage each student as mention below report

student name * total mark percentage
strollstidmathsciencehistorygeographyAABBCCDDEEFFGGtotalclassgrade
Tom
Super User Tom
Super User

Still doesn't make any sense. Perhaps if you put in some actual numbers?

What are the variable STROLL and STID?  They look to me like student ID numbers.  So do you want one row per student?  Then what variable are you summarizing away?  Why do you still have columns for MATH, SCIENCE, etc if you want to summarize grades?

You seem to want to make columns for each student (assuming the variable STNAME is student name).  What number is it that you want to appear under column for when STNAME='AA'?  How many rows do you expect to see in the result for your sample data?

Ksharp
Super User

As Tom said, still can't understand what you want .

data have;
infile datalines expandtabs;
input stroll $     stid $     stname      $ math     science     history     geography     total     class $     grade $;
datalines;
111     s111     AA     60     50     45     60     215     I     B
212     s212     BB     70     50     30     60     210     II     B
324     S324     CC     70     80     50     70     270     III     A
456     S456     DD     60     70     60     60     250     IV     A
578     S578     EE     70     30     30     60     190     V     C
678     S678     FF     40     60     40     40     180     VI     B
789     S789     CC     60     40     50     70     220     VII     B
987     S987     GG     80     30     40     50     200     IX     A
;
run;
proc tabulate data=have;
class stroll     stid      math     science     history     geography      class     grade  stname ;
var total ;
table stroll*stid*math     *science*     history*     geography*     class*     grade ,stname*total*pctsum;
run;

 

Ksharp

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 4 replies
  • 846 views
  • 0 likes
  • 3 in conversation