Hi!
I have tried to create a dummy-variable where "1" indicates that the event (case_start) has occured, and "0" the opposite. "1" should indicate that the event (Case_start) occured after 01.01.2018, and "0" should indicate that the event (case_start) has occured before 01.01.2018.
data tuetravelexpenses_cases;
set tuetravelexpenses_cases;
if '04OCT2016:23:00:00'<case_start<'31DES2017:23:00:00' then observation_period='0';
run;
My problem is that every event gets "0", instead of only the events before 01.01.2018. I have also tried
if case_start>31DES2017:23:00:00" then observation_period="0", but i get the same result.
Can someone help?
Assuming the values of CASE_START are true SAS date-time values (and not character strings or SAS date values)
if '04OCT2016:23:00:00'dt<case_start<'31DES2017:23:00:00'dt then observation_period='0';
Also, not sure why you want the zero in quotes as a character variable, you could just use 0 with no quotes.
Assuming the values of CASE_START are true SAS date-time values (and not character strings or SAS date values)
if '04OCT2016:23:00:00'dt<case_start<'31DES2017:23:00:00'dt then observation_period='0';
Also, not sure why you want the zero in quotes as a character variable, you could just use 0 with no quotes.
Maxim 2: Read the Log. If that is not sufficient to give you a clue, post it here, so we can explain what happens. Use </> to post the log.
Here:
if '04OCT2016:23:00:00'<case_start<'31DES2017:23:00:00'
you use character values that are not SAS datetime literals (constants). Datetime literals must be written with correct month names (DEC for December, for instance) and the closing quote must be followed immediately by the letters dt.
Correct! It worked
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.