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

I am trying to run a simple Anova procedure. Could anyone tell me by looking at the below code what am I doing wrong? I need to get some type of output data beside just listing the dollar amount to the number next to it.

DATA ONE; FIRSTOBS=2 DLM='09'X
INPUT FREQ $ LOC;
Cards;
$36,198 1
$44,166 4
$31,874 4
$32,691 1
$41,259 4
$32,126 4
$42,924 2
$39,338 2
$35,166 1
$33,664 1
$41,027 4
$31,159 4
$37,166 3
$34,696 3
$33,226 3
$33,386 3
$35,166 1
$38,655 1
$31,835 2
$43,235 2
$40,600 2
$35,901 3
$34,505 3
$31,184 1
$30,064 3
$27,274 4
$30,844 3
$35,358 4
$34,280 2
$48,631 2
$31,960 4
$43,839 2
$30,778 1
$32,019 3
$33,096 3
$31,606 3
$33,549 4
$41,901 2
$39,196 2
$32,306 1
$29,851 3
$34,098 1
$38,091 3
$33,081 4
$35,541 2
$37,848 1
$36,335 4
$32,533 1
$33,546 3
$43,269 4

INPUT FREQ LOC;
IF LOC=1 THEN REGION='Southeast';
IF LOC=2 THEN REGION='Northeast';
IF LOC=3 THEN REGION='Midwest';
IF LOC=4 THEN REGION='WEST';
RUN;
PROC PRINT;
RUN;
PROC ANOVA;
CLASS REGION;
MODEL MEDINC=REGION;
MEANS REGION/SCHEFFE TUKEY LSD SNK ALPHA=0.05;
RUN;
*/PROC GLM;
*CLASS REGION;
*MODEL FREQ=REGION;
*CONTRAST 'CENTRAL CITY VS. SUBURBS AND RURAL' REGION -1 0.5 0.5;
*MEANS REGION/SCHEFFE TUKEY LSD SNK ALPHA=0.1;
*RUN;
/*PROC NPAR1WAY ANOVA WILCOXON;
CLASS REGION;
VAR FREQ;
RUN;*/

1 ACCEPTED SOLUTION

Accepted Solutions
timmelvin981
Fluorite | Level 6

Thank you! The one that you did worked for me also. I am also attempting to do this code with the same one.

/PROC GLM;
CLASS REGION;
MODEL FREQ=REGION;
CONTRAST 'CENTRAL CITY VS. SUBURBS AND RURAL' REGION -1 0.5 0.5;
MEANS REGION/SCHEFFE TUKEY LSD SNK ALPHA=0.1;
RUN;
PROC NPAR1WAY ANOVA WILCOXON;
CLASS REGION;
VAR FREQ;
RUN;

It is also not working. I really appreciate your help as I am beyond a SAS novice! 

View solution in original post

7 REPLIES 7
Astounding
PROC Star

First, let's clean up the DATA step in a few ways.  Abbreviating the data lines for readability (you wouldn't actually do that), here is an improved version:

 

DATA ONE; 

informat FREQ dollar8.;
INPUT FREQ LOC;

IF LOC=1 THEN REGION='Southeast';
else IF LOC=2 THEN REGION='Northeast';
else IF LOC=3 THEN REGION='Midwest';
else IF LOC=4 THEN REGION='WEST';
Cards;
$38,655 1
$31,835 2
$43,235 2
$40,600 2
$35,901 3
$34,505 3

;

 

This version makes FREQ a numeric variable instead of character.  

 

In the ANOVA, one thing stands out as possibly being a problem.  In a MEANS statement, are you permitted to use a character variable?  (I actually don't know the answer to that.)  Instead of using REGION, you could certainly use LOC (in all three places).


PROC ANOVA;
CLASS REGION;
MODEL MEDINC=REGION;
MEANS REGION/SCHEFFE TUKEY LSD SNK ALPHA=0.05;
RUN;

timmelvin981
Fluorite | Level 6

Thanks for the help but it is still not wanting to run the ANOVA

Astounding
PROC Star

You'll have to help out here.  Post the log, so we can see what is not working.

art297
Opal | Level 21

The following works for me:

DATA ONE; 
  infile cards DLM='09'X;
  INPUT medinc comma7. LOC;
  IF LOC=1 THEN REGION='Southeast';
  else IF LOC=2 THEN REGION='Northeast';
  else IF LOC=3 THEN REGION='Midwest';
  else IF LOC=4 THEN REGION='WEST';
  Cards;
$36,198 1
$44,166 4
$31,874 4
$32,691 1
$41,259 4
$32,126 4
$42,924 2
$39,338 2
$35,166 1
$33,664 1
$41,027 4
$31,159 4
$37,166 3
$34,696 3
$33,226 3
$33,386 3
$35,166 1
$38,655 1
$31,835 2
$43,235 2
$40,600 2
$35,901 3
$34,505 3
$31,184 1
$30,064 3
$27,274 4
$30,844 3
$35,358 4
$34,280 2
$48,631 2
$31,960 4
$43,839 2
$30,778 1
$32,019 3
$33,096 3
$31,606 3
$33,549 4
$41,901 2
$39,196 2
$32,306 1
$29,851 3
$34,098 1
$38,091 3
$33,081 4
$35,541 2
$37,848 1
$36,335 4
$32,533 1
$33,546 3
$43,269 4
;

PROC ANOVA;
CLASS REGION;
MODEL MEDINC=REGION;
MEANS REGION/SCHEFFE TUKEY LSD SNK ALPHA=0.05;
RUN;

Art, CEO, AnalystFinder.com

 

timmelvin981
Fluorite | Level 6

Thank you! The one that you did worked for me also. I am also attempting to do this code with the same one.

/PROC GLM;
CLASS REGION;
MODEL FREQ=REGION;
CONTRAST 'CENTRAL CITY VS. SUBURBS AND RURAL' REGION -1 0.5 0.5;
MEANS REGION/SCHEFFE TUKEY LSD SNK ALPHA=0.1;
RUN;
PROC NPAR1WAY ANOVA WILCOXON;
CLASS REGION;
VAR FREQ;
RUN;

It is also not working. I really appreciate your help as I am beyond a SAS novice! 

art297
Opal | Level 21

Like with your original code, you refer to a variable called FREQ, but don't have any such variable in your dataset. I presume that you were trying to run:

PROC GLM data=one;;
CLASS REGION;
MODEL MEDINC=REGION;
CONTRAST 'CENTRAL CITY VS. SUBURBS AND RURAL' REGION -1 0.5 0.5;
MEANS REGION/SCHEFFE TUKEY LSD SNK ALPHA=0.1;
RUN;

PROC NPAR1WAY data=one ANOVA WILCOXON;
CLASS REGION;
VAR MEDINC;
RUN;

Art, CEO, AnalystFinder.com

 

timmelvin981
Fluorite | Level 6

Art,

Just wanted to say thank you for your help. It was very much appreciated.

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