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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.