BookmarkSubscribeRSS Feed
Emma_at_SAS
Lapis Lazuli | Level 10

I have a large survey and I need to use PROC SURVEYFREQ and SURVEYMEANS to create summary tables to describe hundreds of variables to share with our team. Before, I was creating all summary tables in Word by ODS WORD and then copy and paste them into row tables in the following format. I was creating hundreds of rows for each variable. Now, I wonder if I may create these tables in SAS instead of changing the format in Word which table me a long time. 

Thanks.

 

Additional text

[name of the variable-column in the dataset]

Label of the variable

 

Mean

63.75

Standard Deviation

43.14

95% CI

47.54, 79.96

N

59

 

Additional text

3 REPLIES 3
ballardw
Super User

The generic start is going to be to place the desired values into a data set. That means adding ODS OUTPUT statements to the Surveyfreq , Surveymeans or other procedure code. You need to determine the name of the ods table created by the procedure to do so. Specific tables depend on the options you are using.

Then possibly "massage" the result a bit to ensure the data is in the proper structure and content prior to using one of the report procedures such as Proc Report, Tabulate or Print to generate the output.

 

Best would be to provide a small example data set, or use one of the SAS supplied sets like SASHELP.CLASS or SASHELP.CARS with your Surveyfreq or Surveymeans code and then provide an example of the actual output.

A big question is going to be "where does the additional text" other than variable names or labels come from?

Emma_at_SAS
Lapis Lazuli | Level 10

Thank you, ballardw! Very good suggestions. I take the steps in a smaller sample and let the group know how it went.

 

The "additional text" is coming from a separate word file. I think I need to copy and paste them manually into my SAS code as a TITLE or something.

We are going to repeat this same survey annually for a couple of years. I thought one option would be to copy/paste the var_name, var_label, and extra_text in an Excel file and concatenate my PROC SURVEY code from Excel into SAS. Then that would be easier to edit for the next years as well.

I appreciate it if you have a good suggestion for that part as well.

 

Thanks

 

PhilC
Rhodochrosite | Level 12

You can play with some of the ideals here.  This creates an HTML5 document, but if you replace the extension with dot-"DOC" MS word will open the HTML as  a document.

 

ODS HTML5 FILE="EGHTML.doc";

ODS HTML5 text="<Table border=1><TR><TD>";

  proc ODSTEXT;
    p "Additional text"/ style={font_weight=bold};
    p "[name of the variable-column in the dataset]";
  run;

ODS HTML5 text="</TD><TD>";

  proc ODSTEXT;
    p "Label of the variable"/ style={fontweight=bold};
    p;
  proc freq data=sashelp.cars;
    table cylinders;
    proc ODSTEXT;
    p;
    p "Additional text";
  run;

ODS HTML5 text="</TD></TR></Table>";

Basically I've written HTML code. wrapped around ODS output.  This was easier than I thought it would be.   I've done similar things with RTF,  but that was much more involved, as I remember.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 3 replies
  • 642 views
  • 3 likes
  • 3 in conversation