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

Hi,

I have two variables. Gender (male, female) and Level (High, Medium, Low)

 

Male =1

Female =2

High=1

Medium=2

Low=3

 

My final data set example

 

ValueGenderLevel
1011
511
611
211
812
912
1022
1022
823
623
423
1223

 

Now I want descriptive statistics and univariate regression from the above data set in the following way. What would be sas code? Please help.  The following is just an example not the actual answer of the above

 LevelMeanStd. dev
MaleHigh8.002.828
 Medium10.002.828
 Low8.832.563
 Total8.942.711
FemaleHigh9.002.828
 Medium8.003.033
 Low14.173.312
 Total10.394.002
TotalHigh8.502.747
 Medium9.002.985
 Low11.503.966
 Total9.673.448
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
If you can get the report but need to add formatting, use PROC FORMAT first:

proc format;
value sex 1='Male' 2='Female';
run;

Then within the procedure that generates the report apply the format:

format gender sex.;

View solution in original post

5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi:
PROC MEANS or PROC TABULATE would be where I would start.
Cynthia
abdulla
Pyrite | Level 9
I know the proc means work. But it will not give me name like male and female. rather it will say mean for 1 and mean for 2. I want the result as the example given
Cynthia_sas
SAS Super FREQ
Hi:
Not true. Procedures will give you formatted values for Male and Female, etc. You just need a user-defined format such as we show in Programming 1.

Cynthia
Astounding
PROC Star
If you can get the report but need to add formatting, use PROC FORMAT first:

proc format;
value sex 1='Male' 2='Female';
run;

Then within the procedure that generates the report apply the format:

format gender sex.;
Astounding
PROC Star
You claimed that you know how to do this, getting stats for 1 and 2 instead of Male and female. Post your program and I will show how to modify it to get the report that you want.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 901 views
  • 1 like
  • 3 in conversation