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

Hi Everyone

When I run the below data step and see the result, I am not getting any records where there is a 'y' flag and there definitely should be (no errors either). When I run some of these operators individually, I do get 'y' flags. Is there some syntax issue with combining operators?

Paul

data s0All (keep=cnty_name County place Year start stop exit filing_cat1 agecat4 Jur2012 Jur2011 Jur2010);

set workep;

if (exit="ZTC" and start < 01/02/2012) or (stop < 01/02/2012) then Jur2012="y";

else Jur2012="n";

if (exit="ZTC" and start < 01/02/2011) or (stop < 01/02/2011 and start < 01/02/2011) then Jur2011="y";

else Jur2011="n";

if (exit="ZTC" and start < 01/02/2010) or (stop < 01/02/2010 and start < 01/02/2010) then Jur2010="y";

else Jur2010="n";

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Is your start variable a character or a number? Is it formatted as a date?

I think your date part is wrong anyways, should be start<'01Jan2010'd type notation rather than what you have.

You may also want to verify the case of your 'y' to make sure none are 'Y' or "N".

View solution in original post

4 REPLIES 4
Reeza
Super User

Is your start variable a character or a number? Is it formatted as a date?

I think your date part is wrong anyways, should be start<'01Jan2010'd type notation rather than what you have.

You may also want to verify the case of your 'y' to make sure none are 'Y' or "N".

Paul_NYS
Obsidian | Level 7

Hi Reeza, It is a number (01/01/2003), formatted as a date field. However, your suggestion above resolved it. I don't totally understand because it was evaluating it prior. Regardless, thank you.

Paul

Astounding
PROC Star

Paul,

The difference is this.  How would you feel about making this comparison:

if start < 0.5 / 2012 then do;

That's actually the comparison you were making.  01/02/2012 says divide 1 by 2, then divide the result by 2012.  Reeza showed you the right way to refer to a particular day on the SAS date scale.

Good luck.

Paul_NYS
Obsidian | Level 7

Thanks Astounding. I see.

Paul

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1608 views
  • 0 likes
  • 3 in conversation