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

Hello,

 

So, I am attempting to create a report similar to the attached image. sasquestion2.PNG

 

To get the numbers in the original, I used a comprehensive sas data set to create 3 separate tables (male, female, missing) to obtain the frequencies and calculated the totals and percent by hand. I have no idea of how to get started on completely automating the process so any thoughts would be helpful. 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

An example that creates a report of similar structure using a SAS supplied data set you should be able to use:

proc tabulate data=sashelp.class;
   class sex age;
   tables age,
          sex=''*n='' all=''*(n='Total' pctn='%')
          /misstext=' '
   ;
run;

The ='' bits are suppressing default  labels.

Sex is basically the same as your Gender variable for role, Age as grade.

 

There are many appearance options available.

View solution in original post

17 REPLIES 17
PaigeMiller
Diamond | Level 26

In order to write any code, we would need to see (a portion of) your original data. Please provide the data as working SAS data step code, which you can type in yourself or follow these instructions. Do not provide data as screen captures or file attachments.

--
Paige Miller
AVUH777
Obsidian | Level 7

Hey! I'm unable to share any code. Just looking for general ideas on how to create a similar report. Thanks. 

 

 

PaigeMiller
Diamond | Level 26

@AVUH777 wrote:

Hey! I'm unable to share any code. Just looking for general ideas on how to create a similar report. Thanks. 


I didn't ask to see your code, I need to see your data. If you can't send real data, then make some up so that it is organized the same as your real data; put it in the requested form, and show us.

--
Paige Miller
AVUH777
Obsidian | Level 7

Sorry, I misunderstood. Does this help?

 

data WORK.STUDENTS;
input UniqueID Gender $ Grade_Level;
datalines;
89562 F 1
78921 M 2
78961 F 5
46526 M 4
;
run;

 

 

PaigeMiller
Diamond | Level 26

The data (even if it is fake) must match the arrangement of your original data, and must contain all the elements needed to produce the table that you want. There are variables in the table that you want that are not in this data. So, no, this doesn't help.

--
Paige Miller
AVUH777
Obsidian | Level 7

Everything calculated in the report came from the data. Originally, I created new data sets based on gender. So, a table for females, males, and missing gender. Then, calculated the frequency of the gender variable for each table. By hand, I added together the totals and calculated the cumulative percent.

 

 

PaigeMiller
Diamond | Level 26

Where is the freshman, sophomore ... etc. part? It's not in your data.


Where is the Year (on the left of your table it says Enrollment by Grade span 2008-2009)?

--
Paige Miller
AVUH777
Obsidian | Level 7

The entire dataset is from that year so I do not have a year variable. 

PaigeMiller
Diamond | Level 26
data STUDENTS;
input UniqueID Gender $ Grade_Level;
datalines;
89562 F 1
78921 M 2
78961 F 5
46526 M 4
;
run;
proc freq data=students;
   tables grade_level*gender;
run;
--
Paige Miller
AVUH777
Obsidian | Level 7

Thanks! Any idea on how to use SAS to create a similar report in terms of the image I provided? I'm being asked to cut out the use of Microsoft Word (which I used to create the attached image) to create the report and use only SAS. 

Quentin
Super User

Look into examples of using PROC TABULATE.  PROC REPORT would be another option.  

 

If you search lexjansen.com for PROC TABULATE should find lots of papers that could help get you started.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

If you search lexjansen.com for PROC TABULATE should find lots of papers that could help get you started.


Hmm, isn't the information provided there a bit hard to digest for beginners? The site is great, though. Thank you for bringing that (back) to my attention/memory. 

--fja

Quentin
Super User

@fja wrote:

If you search lexjansen.com for PROC TABULATE should find lots of papers that could help get you started.


Hmm, isn't the information provided there a bit hard to digest for beginners? The site is great, though. Thank you for bringing that (back) to my attention/memory. 

--fja


Could be hard to digest for some beginners, but I think it's worth the effort.  There is a wealth of wisdom is papers written by users (and developers).  For a general "how can I make this sort of table" question, reading papers will provide lots of interesting approaches.  It also introduces beginners to the existence of SAS user group conferences, another great way to learn.

 

This paper by guru Art Carpenter has examples similar to yours.   https://support.sas.com/resources/papers/proceedings11/260-2011.pdf

 

I also recommend books for beginners.  I think of Lauren Haworth's book as the classic text on PROC TABULATE.  Sadly, looks like it's out of print. But you can find used versions available online. https://support.sas.com/en/books/authors/lauren-haworth.html

 

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
AVUH777
Obsidian | Level 7
Thank you! I will look into this. 🙂

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 17 replies
  • 1706 views
  • 6 likes
  • 5 in conversation