BookmarkSubscribeRSS Feed
ssas
Calcite | Level 5
Hi,
I will be greatful if any one can help me to break the problem
I have a dataset with following variables
gender agegroup paper1 paper2 web1 web2 .........................
1 1 1 0 0 1
2 3 0 0 1 1
1 2 1 1 1 0
2 3 1 1 0 1

gender 1=male,2=female
age group 1=18-24, 2=25-30 3=31-35
paper read=1 not read=0

i would like to find
gender wise age group wise how many people read at least any of two

Can any one can suggest the best way to find, please see my code
Thanks & Regards,
Suresh

here is my code tried with Proc Freq and Proc Tabulate :
PROC FREQ DATA=WORK.test
ORDER=INTERNAL
;
TABLES gender / NOPERCENT NOCUM SCORES=TABLE;
TABLES agegroup / NOPERCENT NOCUM SCORES=TABLE;
BY paper1 paper2 web1 web2
RUN;

CODE 2 WITH PROC TABULATE :
PROC TABULATE
DATA=work.test1

;
CLASS gender / ORDER=UNFORMATTED MISSING;
CLASS agegroup / ORDER=UNFORMATTED MISSING;
CLASS paper1 / ORDER=UNFORMATTED MISSING;
CLASS paper2 / ORDER=UNFORMATTED MISSING;
CLASS web1 / ORDER=UNFORMATTED MISSING;
CLASS web2 / ORDER=UNFORMATTED MISSING;
TABLE /* Row Dimension */
paper1
paper2
web1
web2

/* Column Dimension */
gender*
agegroup*
N ;
;

RUN;
1 REPLY 1
Doc_Duke
Rhodochrosite | Level 12
Because the data are in one row per person, you can get it with a FREQ TABLE statement like

TABLES paper1*paper2;
BY gender agegroup;

then you just add up all the cells other than the 0-0 one for each age and sex category.

With a DATA step, you could get at it more directly;

DATA new;
SET old;
AnyPaper = paper1*paper2;
RUN;

PROC FREQ DATA=new;
TABLES gender*agegroup*anypaper;
RUN;

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!

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.

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
  • 1 reply
  • 602 views
  • 0 likes
  • 2 in conversation