BookmarkSubscribeRSS Feed
ssas
Calcite | Level 5
Hi could any one suggest the solution
i have data set with the following media variables
newspaer1 paper2 paper3 paper4 web1 web2 web3 radio1 radio2 tv1 tv2 age gender
1 0 1 0 1 0 0 1 1 0 1 2 1
1 1 0 0 0 1 0 0 1 1 1 3 2
1 1 1 0 1 1 1 0 0 0 1 4 1
0 1 0 1 1 1 0 0 1 0 1 1 2
0 0 1 1 0 1 0 1 0 0 1 2 2

i would like to find out cross overs between variables - let us say
how many people read any two news papers and watch web/tv/radio vise versa
then
age vs. gender wise cross sections

for papers,web,radio,tv 1- read, 0-don't read
for age 1: 18-24 , 2: 25-34.........
for gender 1 male, 2 female

i would like to see my out put
1.

anytwonewspapers radio tv web
15 5 6 8


output 2.
web radio tv newspapers1
15 8 9 25


output3:

news papers1xpaper2/paper3/paper4 radio tv web
10 3 8



i tried through summary tables but i couldn't able to figure out.

Many thanks in-advance
ps
1 REPLY 1
Patrick
Opal | Level 21
No idea how you get the sums in your examples with the data you give us.

The following code might give you some hints of how to tackle this challenge:

data have;
infile datalines dlm=' ' dsd truncover;
input
paper1 paper2 paper3 paper4 web1 web2 web3 radio1 radio2 tv1 tv2 age gender;
anytwopapers= (sum(of paper:)=2);
radio= (sum(of radio:)>1);
tv= (sum(of tv:)>1);
web= (sum(of web:)>1);
datalines;
1 0 1 0 1 0 0 1 1 0 1 2 1
1 1 0 0 0 1 0 0 1 1 1 3 2
1 1 1 0 1 1 1 0 0 0 1 4 1
0 1 0 1 1 1 0 0 1 0 1 1 2
0 0 1 1 0 1 0 1 0 0 1 2 2
run;

proc format;
value gender
1='Male'
2='Female'
other='?'
;
quit;

proc tabulate data=have format=8. noseps;
where anytwopapers=1 and (radio=1 or tv=1 or web=1);
class age gender anytwopapers radio tv web;
format gender gender.;
keylabel n=' ' ;
table age all='Total', (gender all='Total')*(anytwopapers radio tv web )
/rts=10;
run; Message was edited by: Patrick

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!

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.

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
  • 608 views
  • 0 likes
  • 2 in conversation