BookmarkSubscribeRSS Feed
apple
Calcite | Level 5

Using SAS EG 7. If I want to apply different format to different categories in proc tabulate, is there a way to do it?

 

For eg, I want to have different grouping for the salary of a male vs a female. Do I have to generate different tables for males and females? Thank you

 


proc format;


value SalaryM

500-<1000='500-<1000'

1000-high='1000 onwards'

;

value SalaryF

500-<1500='500-<1500'

1500-high='1500 onwards'

;


PROC TABULATE DATA=test MISSING F=COMMA9. FORMCHAR='           ';;
CLASS AGE Sex salary / preloadfmt order=data;
Var EX3;
KEYLABEL                N=' '
                                SUM=' '
                                ALL ='TOTAL';
TABLES (ALL AGE=' '),(Sex =' ')*(ALL  Salary=' )/PRINTMISS;
 
RUN;
 
 

 

1 REPLY 1
ballardw
Super User

If I'm attempting something like with Proc tabulate to display it would require either preprocessing the data for and create a single variable like Sex_Salary that was essentially valued as "Male 500 < 1000" "Male 1000+" and such.

OR to recode salary to categories such as 1, 2, 3, 4 and assign the recodes based on gender so that you could have a format like

proc format;
   value SalaryCode
   1='500-<1000'
   2='1000 onwards'
   3='500-<1500'
   4='1500 onwards'
   ;
run;

so with 1 and 2 assigned to males and 3 and 4 assigned to females then that may work. But you would not want to use PRELOADFMT for this variable/format combination as the males would show the female range and vice versa.

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 647 views
  • 0 likes
  • 2 in conversation