BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pinkyloop
Obsidian | Level 7

hi everyone,

i need help with these

1) how do i get the freq for just the front row.this is what i did

proc freq data=merged;
tables seat * sex/nocum ;

run;

2) how do i get the percentage of students that missed 0 classes,1-3 classes or more than 3 classes.

This is what i did;


*Created new data set called newset to recode the missclas variable as Mclass;
data newset;
set merged;
if 0<=missclass<=1 then mclass='Low';
else if 1<=missclass<=3 then mclass='Avg';
else if missclass>3 then mclass= 'High';
run;
proc print data=newset;

*Percent of students that missed class using the newset data;
proc freq data =mclass;
tables mclass/ norow nocol nocum;
title 'Percent of students based on gender and classes Missed';

 

b)i was also thinking of this;

proc format

value $mclass '0'=good

                        '1-3'=fair

                        '3+'=bad

proc freq  data =merged;

    table missclass;

    format missclass $mclass.;

         

please help;

Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@pinkyloop wrote:

 

1) how do i get the freq for just the front row.this is what i did

proc freq data=merged;
tables seat * sex/nocum ;
run;
proc freq data=merged(where=(seat='Front'));
    tables sex;
run;

2) how do i get the percentage of students that missed 0 classes,1-3 classes or more than 3 classes.

 

proc format;
    value missf 0='0' 1-3='1-3' 4-high='>3';
run;
proc freq data=merged;
    tables missclass;
    format missclass missf.;
run;
--
Paige Miller

View solution in original post

11 REPLIES 11
PaigeMiller
Diamond | Level 26

What do you mean by "just the front row"?

 

Please show us what you are getting, and in detail, explain why this isn't what you want and exactly what you do want. Please provide (a portion of) your data for us to see.

--
Paige Miller
pinkyloop
Obsidian | Level 7

the question says 

calculate the percentage of female students who sat in the front row and compare it to the male students who sat in the front row.

usint the proc freq  for the table sex *sex.i get the freq for all the  row of seat both male and females sat.

PaigeMiller
Diamond | Level 26

We don't know how "front row" is identified in the data.


We need to see (a portion of) your data, with explanation.

--
Paige Miller
pinkyloop
Obsidian | Level 7

please see attached part of the data i am working with

Thanks

pinkyloop
Obsidian | Level 7
'front' is identified in the data
PaigeMiller
Diamond | Level 26

@pinkyloop wrote:

 

1) how do i get the freq for just the front row.this is what i did

proc freq data=merged;
tables seat * sex/nocum ;
run;
proc freq data=merged(where=(seat='Front'));
    tables sex;
run;

2) how do i get the percentage of students that missed 0 classes,1-3 classes or more than 3 classes.

 

proc format;
    value missf 0='0' 1-3='1-3' 4-high='>3';
run;
proc freq data=merged;
    tables missclass;
    format missclass missf.;
run;
--
Paige Miller
pinkyloop
Obsidian | Level 7
Thank you so Much!
ballardw
Super User

@pinkyloop wrote:
Thank you so Much!

@PaigeMiller's solution is one demonstration of an extremely powerful tool in SAS: Formats. Almost any grouping that needs to be done based on a single variable should at least consider the use of a format instead of adding a variable.

 

The groups created by formats are generally honored by most analysis, reporting and graphing procedures. So they can be extremely handy for examining data behavior. You can create multiple formats and see the results by just changing the format associated for use in a procedure.

 

Also if you have lists that change occasionally, think store, building name, teacher it can be easier to modify a format to use the current association then to modify data sets.

 

And the flip side of the format, the informat (invalue statement in Proc Format) can be used to read data into consistent forms or identify data entry errors or unexpected values.

pinkyloop
Obsidian | Level 7

hi everyone,

i need help with these

1) how do i get the freq for just the front row.this is what i did

proc freq data=merged;
tables seat * sex/nocum ;

run;

2) how do i get the percentage of students that missed 0 classes,1-3 classes or more than 3 classes.

This is what i did;


*Created new data set called newset to recode the missclas variable as Mclass;
data newset;
set merged;
if 0<=missclass<=1 then mclass='Low';
else if 1<=missclass<=3 then mclass='Avg';
else if missclass>3 then mclass= 'High';
run;
proc print data=newset;

*Percent of students that missed class using the newset data;
proc freq data =mclass;
tables mclass/ norow nocol nocum;
title 'Percent of students based on gender and classes Missed';

 

b)i was also thinking of this;

proc format

value $mclass '0'=good

                        '1-3'=fair

                        '3+'=bad

proc freq  data =merged;

    table missclass;

    format missclass $mclass.;

         

please help;

Thanks 

PaigeMiller
Diamond | Level 26

There's no need to post the same question twice. All replies should go into your other thread.

https://communities.sas.com/t5/SAS-Studio/proc-freq-help/td-p/594726

--
Paige Miller

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

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 11 replies
  • 3129 views
  • 1 like
  • 3 in conversation