Hi Everyone,
I am totally new to sas and I am trying to find a way to specify a particular month when creating my date variable. I have included the problem question in the comment of my code.
/*Question 4: Using the Hosp SAS dataset, create a new temporary SAS dataset which contains only patients born after August 05, 1950. Extract the day from the birth date (DOB) and the year from the admission date (AdmitDate). Create a new date variable named DateNew using these 2 variables and the month of May.Calculate each patient's age as of January 27, 2018. And using a date interval function with the ‘sameday’ option, identify a scheduled return visit date that is 5 months after the discharge date. Format all dates as YYYY-MM-DD and print observations for patients who have IDs between 15 and 45 inclusive.*/;
libname cb "I:\My Documents\552\codybook";
data thosp;
set cb.hosp (where = (DOB gt '05Aug1950'd));
/*Extracting day and year from DOB and AdmitDate Respectively*/
dy = day(DOB);
yr = year(AdmitDate);
mnth = mnth(‘May’);
DateNew = mdy(mnth,dy,yr);
Age = yrdif(DOB,'27Jan2018'd);
ReturnVisitDate =intnx('month', DischrDate, 5, 'sameday');
format DOB yymmdd10. ReturnVisit yymmdd10. AdmitDate yymmdd10. DateNew yymmdd10. DischrDate yymmdd10.;
run;
proc contents data = thosp;
run;
proc print data = thosp (obs=2);
run;
proc print data = thosp;
where ID in (15:45);
run;
Please see the attached screenshot error I keep getting and my code below: