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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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