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

Hi,
Can someone help to decipher this code?


TARGET_TKLPVS_ACQ=(TARGET_TKFLINK_ACQ OR TARGET_PVS_ACQ);

where,
TARGET_TKFLINK_ACQ and TARGET_PVS_ACQ are the variables, and TARGET_TKLPVS_ACQ is the product(new column).

Is this similar to the boolean operator where either one of them is true then it will produce 1 and produce 0 when false?

- But from the expected result, regardless of true/false it produce 0.

Is there any plausible answer for this?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Experiment...

 

33   data _null_;
34   TARGET_TKFLINK_ACQ = 1;
35   TARGET_PVS_ACQ = 0;
36   TARGET_TKLPVS_ACQ=(TARGET_TKFLINK_ACQ OR TARGET_PVS_ACQ);
37   put _all_;
38   run;

TARGET_TKFLINK_ACQ=1 TARGET_PVS_ACQ=0 TARGET_TKLPVS_ACQ=1 _ERROR_=0 _N_=1
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.03 seconds
PG

View solution in original post

3 REPLIES 3
Reeza
Super User

Anything greater than 0 is true in SAS and that will operate similar to a Boolean operator. 

PGStats
Opal | Level 21

Experiment...

 

33   data _null_;
34   TARGET_TKFLINK_ACQ = 1;
35   TARGET_PVS_ACQ = 0;
36   TARGET_TKLPVS_ACQ=(TARGET_TKFLINK_ACQ OR TARGET_PVS_ACQ);
37   put _all_;
38   run;

TARGET_TKFLINK_ACQ=1 TARGET_PVS_ACQ=0 TARGET_TKLPVS_ACQ=1 _ERROR_=0 _N_=1
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.03 seconds
PG
Astounding
PROC Star

Yes, you will get a Boolean result.  SAS evaluates that 0 and missing values are false, and anything else (whether positive or negative, integer or decimal) is true.

 

If you are getting all zeros and expected something different, check the spelling of your variable names first, and the values second.  There is no room for SAS to go wrong when evaluating true vs. false.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 725 views
  • 1 like
  • 4 in conversation