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

Hey Guys, I am very new to this SAS coding stuff. I just have one simple question. I have a variable that has 5 different categories, 0,1,2,3,4. However, for my ANOVA analysis I need the variable to only consist of 1,2,3,4. How would I go about editing my variable to get rid of the 0 and create a new variable with categories 1, 2, 3, 4?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Do I understand correctly - you are talking about one variable that can hold one of 5 values 0-4 ?

And you want to run the ANOVA procedure neglecting those observation wit value=0 ?

If this is the case use next syntax:

Proc anova data=<data set name>
        (where=(<variable name> ne 0)) ...

View solution in original post

3 REPLIES 3
Shmuel
Garnet | Level 18

Do I understand correctly - you are talking about one variable that can hold one of 5 values 0-4 ?

And you want to run the ANOVA procedure neglecting those observation wit value=0 ?

If this is the case use next syntax:

Proc anova data=<data set name>
        (where=(<variable name> ne 0)) ...
kjvander
Calcite | Level 5
Thanks!!
ballardw
Super User

@kjvander wrote:

Hey Guys, I am very new to this SAS coding stuff. I just have one simple question. I have a variable that has 5 different categories, 0,1,2,3,4. However, for my ANOVA analysis I need the variable to only consist of 1,2,3,4. How would I go about editing my variable to get rid of the 0 and create a new variable with categories 1, 2, 3, 4?

 

Thanks


If the 0 value actually represents something like "not answered" "not collected" "unavailable" you might be better off setting the value to the SAS missing value. That way the 0 doesn't get used for almost any purpose unless specifically requested.

 

The missing values excluded from numerical calculations. The mean of 0, 1, 2, 3, 4 would be 2. If you set the 0 to missing then you would have a mean of 2.5.

 

The concept of missing is fairly important in many places. Do you want the value included in the "n" of any statistic such as mean, standard deviation or even min and max? If the answer to that is "no" then missing is likely what you want.

The modeling procedures will not use any record with missing values for the variables in the model statement generally, so no additional code would have been needed.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 755 views
  • 0 likes
  • 3 in conversation