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

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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