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

Hi SAS coders,

 

I am having trouble with this code:

PROC REPORT DATA=COLANLYS.COMBINED_ANALYSIS;
COLUMN demo_edupctn3(MEAN,STD) demo_povpctn (MEAN,STD) riskfactors_countyestimate (MEAN,STD) 
outcomes_adults_mental_distr (MEAN,STD);
DEFINE demo_edupctn3  / ANALYSIS MEAN STD FORMAT=4.1;
DEFINE demo_povpctn  / ANALYSIS MEAN STD FORMAT=4.1;
DEFINE riskfactors_countyestimate / ANALYSIS MEAN STD FORMAT=4.1;
DEFINE outcomes_adults_mental_distr / ANALYSIS MEAN STD FORMAT=4.1;
RBREAK AFTER / SUMMARIZE;
RUN;
 

It gives me an error that says:

ERROR: There is more than one statistic associated
with the column defined by the following elements.
 
Please advise on what I am doing wrong.
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@kcvaldez98 wrote:

 

ERROR: There is more than one statistic associated
with the column defined by the following elements.

You can only have one statistic per variable in a DEFINE statement. You can't request two (or more) statistics per variable in a single DEFINE statement.

 

In PROC REPORT, you can use an ALIAS to get multiple statistics for a single original variable. See this example: 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/n0ldy84v9j7463n1jjkloe7av38c.htm

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

@kcvaldez98 wrote:

 

ERROR: There is more than one statistic associated
with the column defined by the following elements.

You can only have one statistic per variable in a DEFINE statement. You can't request two (or more) statistics per variable in a single DEFINE statement.

 

In PROC REPORT, you can use an ALIAS to get multiple statistics for a single original variable. See this example: 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/n0ldy84v9j7463n1jjkloe7av38c.htm

--
Paige Miller
kcvaldez98
Obsidian | Level 7

Thank you for helping me with that. 

 

I followed that SAS documentation, but I ran into some things I need help with.

 

MY code is this:

PROC REPORT DATA=COLANLYS.COMBINED_ANALYSIS;
   COLUMN N demo_edupctn3 = sd1 
   demo_povpctn = sd2 riskfactors_countyestimate = sd3
outcomes_adults_mental_distr=sd4;
DEFINE N  / 'N';
DEFINE demo_edupctn3  / ANALYSIS MEAN FORMAT=4.1;
DEFINE sd1  / ANALYSIS STD FORMAT = 5.1;
DEFINE demo_povpctn  / ANALYSIS MEAN FORMAT=4.1;
DEFINE sd2  / ANALYSIS STD FORMAT = 5.1;
DEFINE riskfactors_countyestimate / ANALYSIS MEAN FORMAT=4.1;
DEFINE sd3  / ANALYSIS STD FORMAT = 5.1;
DEFINE outcomes_adults_mental_distr / ANALYSIS MEAN FORMAT=4.1;
DEFINE sd4  / ANALYSIS STD FORMAT = 5.1;
RUN;
My output looks like this:
Screen Shot 2023-11-28 at 2.41.48 PM.png
I want it where it shows the MEANS and Standard deviations and I think this is only standard deviations.
Please advise.
PaigeMiller
Diamond | Level 26

you have to put the variable for the means into the COLUMN statement.

--
Paige Miller
kcvaldez98
Obsidian | Level 7
Would that also be an alias variable or the original variable that I am looking at?
PaigeMiller
Diamond | Level 26

Follow the example shown in the link I gave.

 

There, there is a variable name (and in the DEFINE statement the statistic SUM is specified), followed by two aliases, one for statistic MIN and one for statistic MAX.

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 38621 views
  • 1 like
  • 2 in conversation