Tabulate Multiple Longitudinal variables

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Tabulate Multiple Longitudinal variables

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.            

 


Accepted Solutions
Solution
‎06-13-2016 04:15 AM
Super User
Posts: 10,028

Re: Tabulate Multiple Longitudinal variables

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


All Replies
Solution
‎06-13-2016 04:15 AM
Super User
Posts: 10,028

Re: Tabulate Multiple Longitudinal variables

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;

Super User
Posts: 11,343

Re: Tabulate Multiple Longitudinal variables

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

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 227 views
  • 2 likes
  • 3 in conversation