Hi friends,
I currently have a dataset with variables like this:
Partner1 Partner2 Partner3 Job1 Job2 Job3
where both Partner and Job are categorical variables (Job=Yes/No, Partner = Partnered/Not Partnered), and the number after the variable represents the time point in which the variable was observed.
I want to make a cross tabulated table that shows Partner status by Job status at all points in time.
I want it to look like this:
where each cell has the count of people in each group. Ive been using proc tabulate, and that seems to work if the row variable is the same at all time points, but im not sure how to get it to consider a new variable for another time point.
Any help is appreciated.
You have to change the data structure before using proc tabulate.
data want;
set have;
job=Job1;output;
job=Job2;output;
job=Job3;output;
run;
proc tabulate data=want;
class job Partner1 Partner2 Partner3;
table job,Partner1 Partner2 Partner3;
run;
You have to change the data structure before using proc tabulate.
data want;
set have;
job=Job1;output;
job=Job2;output;
job=Job3;output;
run;
proc tabulate data=want;
class job Partner1 Partner2 Partner3;
table job,Partner1 Partner2 Partner3;
run;
If your data has "time" variable, a variable to indicate partner status and job status similar to:
Time Partner Job
1 Yes Yes
1 No Yes
2 Yes No
etc.
then
proc tabulate data=have;
class time partner job;
table job,
time*Parter*n='';
run;
should work unless you have missing values somewhere
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.
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.