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

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:

 

table.PNG

 

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.            

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

View solution in original post

2 REPLIES 2
Ksharp
Super User

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;

ballardw
Super User

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

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1057 views
  • 2 likes
  • 3 in conversation