Hi;
I should know how to create a dummy SAS set after all these years but I have forgotten. Code is below.
Once this is resolved I will post my actual question in a separate post.
In short 2/3 of the dates are not being posted as desired (Event_dt & Death_dt) . Thank you for your assistance.
data have;
informat ID 8. Discharge DDMMYY10. EVENT 8. EVENT_DT DDMMYY10. DEATH 8. DEATH_DT DDMMYY10.;
input ID Discharge DDMMYY10. EVENT EVENT_DT DDMMYY10. DEATH DEATH_DT DDMMYY10.;
format Discharge DDMMYY10. EVENT_DT DDMMYY10. Death_dt DDMMYY10. ;
datalines;
1 01/01/2020 1 01/15/2020 0 01/20/2020
2 01/01/2020 0 . 1 01/17/2020
3 01/01/2020 0 . 0
;
run;
First, if you provide an INFORMAT statement then placing informat on the INPUT is not needed.
Second, make sure that your informat actually matches your data.
You have dates like 01/15/2020 and attempt to read with a DDMMYY10. informat (i.e. Day Month Year)15 cannot be a month. It appears that the informat you that you want to use is MMDDYY10.
data have; informat ID 8. Discharge MMDDYY10. EVENT 8. EVENT_DT MMDDYY10. DEATH 8. DEATH_DT MMDDYY10.; input ID Discharge EVENT EVENT_DT DEATH DEATH_DT ; format Discharge DDMMYY10. EVENT_DT DDMMYY10. Death_dt DDMMYY10. ; datalines; 1 01/01/2020 1 01/15/2020 0 01/20/2020 2 01/01/2020 0 . 1 01/17/2020 3 01/01/2020 0 . 0 . ; run;
You didn't have any problems with discharge date because 01/01 used 1 for a month (sort of regardless of DDMMYY or MMDDYY considerations).
More explanation, please.
I don't know what the desired outcome is, you didn't say. You only said that its not giving you the desired outcome.
Furthermore, I think the phrase "dummy SAS set" has no meaning to me, and so I request further explanation on that as well.
@PaigeMiller -By dummy set I mean -this is not a real dataset but rather used for examples.
As to outcomes- the event_dt and death_dt dates are NOT appearing in the dataset as I get an error for "invalid" data.
If you run the code you see they do not appear.
Thank you.
Here's what I see in the log, which you should see too
NOTE: Invalid data for EVENT_DT in line 1010 16-25. NOTE: Invalid data for DEATH_DT in line 1010 29-38. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 1010 1 01/01/2020 1 01/15/2020 0 01/20/2020 ID=1 Discharge=01/01/2020 EVENT=1 EVENT_DT=. DEATH=0 DEATH_DT=. _ERROR_=1 _N_=1 NOTE: Invalid data for DEATH_DT in line 1011 29-38.
It is looking for EVENT_DT in columns 16-25. What data is in columns 16-25? 01/15/2020. It is also saying that 01/15/2020 is "invalid data". You are trying to read this in with informat DDMMYY10. Please look at this carefully and see if you can figure out what the error is here that causes 01/15/2020 to be "invalid data".
First, if you provide an INFORMAT statement then placing informat on the INPUT is not needed.
Second, make sure that your informat actually matches your data.
You have dates like 01/15/2020 and attempt to read with a DDMMYY10. informat (i.e. Day Month Year)15 cannot be a month. It appears that the informat you that you want to use is MMDDYY10.
data have; informat ID 8. Discharge MMDDYY10. EVENT 8. EVENT_DT MMDDYY10. DEATH 8. DEATH_DT MMDDYY10.; input ID Discharge EVENT EVENT_DT DEATH DEATH_DT ; format Discharge DDMMYY10. EVENT_DT DDMMYY10. Death_dt DDMMYY10. ; datalines; 1 01/01/2020 1 01/15/2020 0 01/20/2020 2 01/01/2020 0 . 1 01/17/2020 3 01/01/2020 0 . 0 . ; run;
You didn't have any problems with discharge date because 01/01 used 1 for a month (sort of regardless of DDMMYY or MMDDYY considerations).
Valid point on the dates-Thank you.
I was was switching back and forth dates for something else and missed that.
Also the tips of not needing the informat in both places.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.