BookmarkSubscribeRSS Feed
nep87
Calcite | Level 5

Hi all,

I am looking for help pooling frequencies and percentages of categorical variables from PROC SURVEYFREQ in PROC MIANALYZE. I've attached the codes below. I've also attached the error in the log and the dataset with frequency and percentages. Thank you so much.

proc sort data=des.apoe; by _imputation_ ;run;
proc surveyfreq data=des.apoe;
stratum raestrat;
cluster raehsamp;
weight r7wtresp;
by _imputation_;
where wave=7;
tables alc smoke gender race_eth maritalstat;
ods output ONEWAY=catoutfull;
run;
/**POOL STATISTICS**/
proc sort data=CATOUTFULL; by _IMPUTATION_ TABLE ;run; proc mianalyze data=CATOUTFULL (WHERE=(Table= "Table Alc")); title 'ALCOHOL'; by _IMPUTATION_ TABLE; modeleffects percent ; stderr stderr ; run;

 

2 REPLIES 2
ballardw
Super User

The error is very clear, it is missing values for the stated variable for By groups. Note that every single one of your Total lines in the output set from Surveyfreq meets this condition.

 

Note that using BY and WHERE in the surveyprocs may be a bit of a valid analysis problem as complex weights are likely not applied correctly. Adding your by and where variables as Domains or table variables and selecting the proper records is generally the better approach.

nep87
Calcite | Level 5

Thank you. Besides that, I figured out that I had to run the surveyfreq by imputation. Just in case someone might need this I have copied the codes below.

proc surveyfreq data=DES.Dsrtlongfull;
STRATUM RAESTRAT;
CLUSTER RAEHSAMP;
WEIGHT R7WTRESP;
by _imputation_;
where wave=7;
tables ALC gender/ nototal ;
ods output ONEWAY=CATOUTFULL;
run;
************************************************************************;
PROC PRINT DATA=CATOUTFULL;RUN;
/**POOL STATISTICS**/
proc sort data=CATOUTFULL; by alc _IMPUTATION_  ;run;
proc mianalyze data=CATOUTFULL;
by alc;
title 'ALCOHOL';
modeleffects percent; 
stderr stdErr;
run;
proc mianalyze data=CATOUTFULL;
by alc;
title 'ALCOHOL';
modeleffects Frequency; 
stderr stdDev;
run;

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!
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
  • 680 views
  • 2 likes
  • 2 in conversation