Hi all,
I am having trouble reading in the dates for this problem. I keep getting the wrong dates read in for some observations, and missing values for the rest.
For the first report, you need to determine on what date the patients' next appointment should fall. If, at the last appointment, a patient is 45 or less, she should be seen again in (exactly) two years. If a patient is older than 45, she should be seen again in (exactly) one year. For the report, simply print the patient's name, their last appointment date, their age, and the next appointment date. (Suppress the printing of the observation number.)
This is the data for the problem.
Please post your code.
OPTIONS PS=58 LS=72 NODATE NONUMBER;
LIBNAME stat481 'C:\stat481\data';
DATA scheduling (drop=bdate);
input patient & $16. bdate mmddyy10. lastappt;
age= lastappt-bdate;
format lastappt mmddyy10.;
DATALINES;
Jane Smith 10/25/1985 06/15/2010
Laura Smellner 10/20/1947 06/17/2010
Jenna Jones 10/23/1964 07/01/2010
Beth Bonders 10/26/1939 07/14/2010
Grace Johson 10/19/1958 07/29/2010
Mary Contrary 10/22/1981 06/30/2010
Jennifer Palermo 10/21/1953 09/03/2010
Ann Lewis 10/24/1975 08/15/2010
Linda Bentner 10/13/1938 09/04/2010
Francine Scalia 10/14/1963 09/04/2010
Leah Thill 10/15/1949 08/01/2010
Caroline Harris 10/16/1968 08/11/2010
Olivia Knupf 10/17/1972 07/31/2010
Maya Angelson 10/18/1961 07/17/2010
;
RUN;
PROC PRINT Data=scheduling NOOBS;
Title 'Scheduling';
RUN;
This is my output:
Scheduling
patient lastappt age
Jane Smith . .
Laura Smellner 01/08/1960 .
Jenna Jones 05/18/1965 .
Beth Bonders 07/28/1962 -14335
Grace Johson 08/16/1962 -14309
Mary Contrary 03/22/1960 -21763
Jennifer Palermo . .
Linda Bentner 02/08/1960 -21797
Francine Scalia . .
Leah Thill . .
Caroline Harris . .
Olivia Knupf 08/30/1962 -14293
Maya Angelson 03/02/1960 -21779
Change your input statement:
input patient :$20. _patient :$10. bdate :mmddyy10. lastappt :mmddyy10.;
patient = catx(' ',patient,_patient);
drop _patient;
Assign proper formats for both date variables.
Thank you for the help. Would you be able to do this problem without using the catx statement?
@paperboy22 wrote:
Thank you for the help. Would you be able to do this problem without using the catx statement?
Why?
Here's the simplest way that I can think of, to read in the data:
data scheduling (drop=bdate);
informat bdate lastappt mmddyy10.;
format bdate lastappt mmddyy10.;
input fname $ lname $ bdate lastappt;
Continuing the same DATA step, you would need a formula to calculate age in years. While there are more precise methods, here is an easy approximation:
age = (lastapp - bdate) / 365.25;
Finally, you will need to set up some logic to determine the next appointment, based on age.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.