Hello,
I'm using the following code:
proc surveymeans data=historical Nobs mean STDERR sumwgt ;
weight wtanal;
domain nest_yr;
cluster strat_yr;
var
pnc_vst /*continuous vars*/
gest_wk
pnc_mth
mat_age
pre_lb
oth_term
gram
momcig
momlbs;
run;
and instead of the (truncated) output as is:
BC WT:
YEAR
(SUDAAN
NEST
VARIABLE) Variable Label N
----------------------------------------------------------------------------------
2006 PNC_VST Number of Prenatal Care Visits 1013
GEST_WK Gestational Age 1016
PNC_MTH Month of First Prenatal Care Visit 1014
MAT_AGE Maternal Age 1017
PRE_LB Number of Previous Live Births 1016
OTH_TERM Pregnancy History – Other Terminations? 1016
GRAM Birthweight 1017
MOMCIG Number of Cigarettes Per Day 1016
MOMLBS Maternal Weight Gain 1009
2007 PNC_VST Number of Prenatal Care Visits 1333
GEST_WK Gestational Age 1336
PNC_MTH Month of First Prenatal Care Visit 1329
MAT_AGE Maternal Age 1336
PRE_LB Number of Previous Live Births 1336
OTH_TERM Pregnancy History – Other Terminations? 1336
GRAM Birthweight 1336
MOMCIG Number of Cigarettes Per Day 1336
MOMLBS Maternal Weight Gain 1327
2008 PNC_VST Number of Prenatal Care Visits 1196
Could I get the data for pnc_vst, for instance, arranged together for years 2006-2008 and then the data for gest_wk, etc.
kinda like:
2006 PNC_VST Number of Prenatal Care Visits 1013
2007 PNC_VST Number of Prenatal Care Visits 1333
2008 PNC_VST Number of Prenatal Care Visits 1196
Maybe via outputting the data and manipulating it - but any shortcut with proc surveymeans?
Using ODS output and resorting wasn't too painful. Unless there's a more stylish way - that'll work.
I'm not familiar enough with the procedure to know if there is a difference between the use of domain vs the use of strata. In the following, I used the data from http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveymeans_...
and included a stacking option and strata rather than domain.
It appears to provide at least the format that wanted.
proc surveymeans data=IceCreamStudy Nobs mean STDERR sumwgt stacking ;
weight Weight;
*domain nest_yr;
strata nest_yr / list;
cluster StudyGroup;
var
Spending
Group;
run;
Thank you. Seems the output I created from printing parts of the saved ODS table suited my 'boss' (for once) - so I'm leaving it so.
Use output statement to save your this output, then use where variable='PNC_VST' to filter obs.
Ksharp
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.