Hello,
This looks like a simple thing to do, but I'm having a hard time to find an easy solution.
I know this works (specifying exact date):
if '10Apr2008'd <= dob then test=1...
What I want to do is to specify only year and month;
Suppose I already converted dob to year/month format (dob2)...
How can do (this is not a programming language) 'if 10Apr < dob2 then text=1?
I appreciate your suggestions.
Thank you,
Yoko
You ahve to make an assumption if you want to use only year and month. The assumption is that you use always the first day of the month, or the 15th day of the month, or the last day of the month.
You ahve to make an assumption if you want to use only year and month. The assumption is that you use always the first day of the month, or the 15th day of the month, or the last day of the month.
If dob2 is a char type variable formated yymm try
if put(dob, yymmn4.) <= dob2 then ...
pay attention, let date = '07DEC2018'd then
put(date, yymmn6.) = '201812'; /* n stands for number */
put(date, yymms7.) = '2018/12'; /* s stands for slash */
@Yoko wrote:
Hello,
This looks like a simple thing to do, but I'm having a hard time to find an easy solution.
I know this works (specifying exact date):
if '10Apr2008'd <= dob then test=1...
What I want to do is to specify only year and month;
Suppose I already converted dob to year/month format (dob2)...
How can do (this is not a programming language) 'if 10Apr < dob2 then text=1?
I appreciate your suggestions.
Thank you,
Yoko
How did you create dob2?
You question seems to relate to month and year but the shown pseudocode is comparing dob2 to a day of month and month value.
You may be better off sticking with a date and use the month and year functions. You should provide some concrete examples of your dob variables, some comparisons and the desired results. We can't tell if your DOB2 might be numeric or text, formatted as a date or not and whether the reduction to dob2 should consider the beginning of the month or the end of the month in the comparison.
I might guess that want some variation on intnx('month', dob,0,'B') (beginning of month) or intnx('month', dob,0,'E') (end of month) instead of creating a new variable.
What do you mean by converted to month year? Did you convert it to character representing as mmmyy or you just applied format to see them as mmmyy format.
If your just applying only the format than behind the screens it still holds the date value. You can still use full date value to filter ('01jan2018'd ). Make sure you use the proper boundaries for filtering.
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.