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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.