BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
rdemass
Fluorite | Level 6

I am running a model using proc genmod and have run a lsmeans statement. I would like to save only some of the columns of the lsmeans table using the ods output.

General setup:

proc genmod data = data;
	class x;
	model y= x / dist = nb link = log offset = myoff;
	lsmeans x / pdiff;
	ods output 'x Diffs'=diffs(keep = x Estimate 'Standard Error'); 
run;

This gives the error that 'Standard Error' is not valid. This is not surprising because it has a space in the variable name.

I tried specifying as:

ods output 'x Diffs'=diffs(keep = x Estimate 'Standard Error'n);

which adds the 'n' as suggested here but that also does not work. There are many variable names in output tables which contain spaces, so understanding how to do this would be very helpful. Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Are you sure such a variable exists?  Run it without the KEEP= and run a PROC CONTENTS on the resulting dataset.

 

Are you sure that is the right name for the ODS output you want saved to a dataset? 

What do you see when you turn on  ODS TRACE and run the PROC without the ODS OUTPUT statement?

 

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

Are you sure such a variable exists?  Run it without the KEEP= and run a PROC CONTENTS on the resulting dataset.

 

Are you sure that is the right name for the ODS output you want saved to a dataset? 

What do you see when you turn on  ODS TRACE and run the PROC without the ODS OUTPUT statement?

 

rdemass
Fluorite | Level 6

Yes, I see now that what I was trying to use were the labels. All the variable names are created to have no spaces (e.g., StdErr) and can be kept in the keep line easily.

ballardw
Super User

I strongly suspect that you are seeing variable labels that you think are variable names.

Run proc contents on your data set to confirm actual variable names and/or labels.

 

I will also place a small wager that you have a warning similar to this in your log.

WARNING: Output ''x diffs'' was not created.  Make sure that the output
         object name, label, or path is spelled correctly.  Also, verify
         that the appropriate procedure options are used to produce the
         requested output object.  For example, verify that the NOPRINT
         option is not used.

The syntax for the ODS output is

ods output <source data>= the_name_of_your_dataset;

And the the oppropriate source data set would be DIFFS, not "x diffs".  And if the name had actually been "x diffs" that would require the use of another name literal

 

And I suspect that you actually want the Ods output lsmeans=somedataset; which will have

        Alphabetic List of Variables and Attributes

#    Variable    Type    Len    Format       Label

2    Effect      Char      3
4    Estimate    Num       8    D8.4
7    Probz       Num       8    PVALUE6.4    Pr > |z|
5    StdErr      Num       8    D8.4         Standard Error
1    StmtNo      Num       8    BEST4.       Statement Number
3    mfg         Char      1
6    zValue      Num       8    7.2          z Value


Where you can see the label is "Standard Error" for the variable StdErr.

rdemass
Fluorite | Level 6
Yes, the problem was that I was using labels instead of true variable names. I omitted this but I ran multiple lsmeans /pdiff lines as I actually have more than one predictor variable. Hence why I specified 'x diffs', because there are also 'z diffs', for example. I had used the ods trace to figure this out. And I did in fact want the diffs table, not the lsmeans table (so I do not want output lsmeans).

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
  • 4 replies
  • 722 views
  • 0 likes
  • 3 in conversation