BookmarkSubscribeRSS Feed
alothary11
Calcite | Level 5

I am using a dataset with both household and person identifiers. For example the household ID may have 5 or so numeric values (00001) and then there would be a personal identifier in the household (1). How can I load both identifiers into my models?  I have tried to add the variables or simply list both but could not figure out how to properly use both in my model.

proc mixed data=hrs noclprint covtest;
class HHID PN;
model age=
/solution ddfm=bw;
random intercept / subject= HHID PN;
run;

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

Re-titled and moved to stat procedures.

PaigeMiller
Diamond | Level 26

@alothary11 wrote:

I am using a dataset with both household and person identifiers. For example the household ID may have 5 or so numeric values (00001) and then there would be a personal identifier in the household (1). How can I load both identifiers into my models?  I have tried to add the variables or simply list both but could not figure out how to properly use both in my model.

proc mixed data=hrs noclprint covtest;
class HHID PN;
model age=
/solution ddfm=bw;
random intercept / subject= HHID PN;
run;


What happens when you do it this way? Do you get an error? What error?

 

You could modify the input data set to concatenate HHID and PN into a single variable.

--
Paige Miller
alothary11
Calcite | Level 5

Thank you, that is what I ended up doing. I had to concatenate the variables and then use the input function to create a numeric value. 

data ex;set ex.exall;
ID_all = cats(HHID,PN);
run;
data ex2; set ex.exall;
ID= input(ID_all, 8.);
run;

 

Just posting what I found so others might be able to search and find it. Thanks for the replies!

SteveDenham
Jade | Level 19

That would enable you to model a single variance component based on the composite variable.  However, if you wish to model a 2 level design, where person is nested within household, you might try:

 

proc mixed data=hrs noclprint ;
class HHID PN;
model age=
/solution ;
random intercept HHID/ subject= PN;
run;

I removed the covtest option from the PROC MIXED statement, as it depends on a Wald test that is really not a good test given the distribution of variances, and also removed the ddfm=bw, as you now want a containment hierarchy for the variance components.

 

If you truly need to test whether the variance components are non-zero I would recommend changing to PROC GLIMMIX and using the options under the COVTEST statement, which give likelihood ratio based tests that are more appropriate.

 

SteveDenham

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 502 views
  • 0 likes
  • 4 in conversation