BookmarkSubscribeRSS Feed
CathyVI
Lapis Lazuli | Level 10

Hi,

I saw a similar code online.

What is the function of "case" in this codes? what are they use for?

data want;
set have;
if a ne . then come=1; else come=0;
if b ne . then go=1;else go=0;
if c ne . then home=1;else home=0;
case=1;
run;

data want2;
set have2;
if a ne . then come=1;else come=0;
if b ne . then go=1;else go=0;
if c ne . then home=1;else home=0;
case=0;
run;

 

 

6 REPLIES 6
Reeza
Super User
It's a variable and being set to a constant across all the data.
CathyVI
Lapis Lazuli | Level 10

@Reeza Thank you. Are there resources you can share or direct me to for better knowledge?

SASKiwi
PROC Star

SAS documentation is here: SAS Help Center: SAS Help Center: Welcome

Check out free SAS training resources here: New SAS User

Reeza
Super User

In this case not really, it's base knowledge. 

 

It's a simple assignment operation (case=1). The fact that the variable is called case may be confusing and bad design because CASE often means something else in programming. 
However, the best method to test this is to run it and examine the input and output data in my opinion.

Astounding
PROC Star
In the program you have shown, CASE is totally useless. However, it is possible (even likely) that CASE actually gets used later, in programming steps that you have not posted. If you want to know about the purpose of CASE, show how it gets used later.
Tom
Super User Tom
Super User

CASE is the name of a variable.

What does the variable mean?  Your guess is as good as mine.

Spoiler
My guess is that the data in WANT represent the cases and the data in WANT2 represent the controls.  I suspect at some point there will be some statistical testing to see if the cases are different than the controls.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 6 replies
  • 1131 views
  • 6 likes
  • 5 in conversation
OSZAR »