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;
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".
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".
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
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.
Thanks Astounding. I see.
Paul
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.
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.