Hi everyone,
I'm still pretty new to sas.
Here is the situation.
I have a table (Merged1) that has IDnumbers some descriptions and 2 dates, an event date and a consent date. both of the dates are in the format MMDDYY10 and each row has all these variables.
I want to get a data set where the consent date is before the event date. So if an even happened before the consent it will not be in my new data set. I have something like this...
data Sample1;
set merged_data;
where event_date > consent_date;
run;
I know that dates are just numbers counting from a certain date, so I would imagine this would work, but that is not the case.
please and thank you
If your two dates are just character strings that look like dates, just change your code to:
data Sample1; set merged_data; if input(event_date,mmddyy10.) > input(consent_date,mmddyy10.); run;
HTH,
Art, CEO, AnalystFinder.com
Make sure (proc contents) that the date variables are numeric with a MMDDYY10. assigned.
If that is the case, post some examples that illustrate your issues in a data step with datalines.
@Curly wrote:
Hi everyone,
I would imagine this would work, but that is not the case.
please and thank you
What does that mean? How did it not work?
If your two dates are just character strings that look like dates, just change your code to:
data Sample1; set merged_data; if input(event_date,mmddyy10.) > input(consent_date,mmddyy10.); run;
HTH,
Art, CEO, AnalystFinder.com
Example data.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
You need to look into the descriptor portion about how the dates are formated. Use PROC CONTENTS and see weather the dates are char or num and use appropriate method as mentioned by others.
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.