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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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