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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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