Help using Base SAS procedures

proc surveymeans and domain - order of output

Reply
Contributor
Posts: 47

proc surveymeans and domain - order of output

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?

Contributor
Posts: 47

proc surveymeans and domain - order of output

Using ODS output and resorting wasn't too painful.  Unless there's a more stylish way - that'll work.

PROC Star
Posts: 7,363

proc surveymeans and domain - order of output

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;

Contributor
Posts: 47

proc surveymeans and domain - order of output

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.

Super User
Posts: 9,681

proc surveymeans and domain - order of output

Use output statement to save your this output, then use where variable='PNC_VST' to filter obs.

Ksharp

Ask a Question
Discussion stats
  • 4 replies
  • 170 views
  • 0 likes
  • 3 in conversation