Hello team,
I need to create a dataset and I want to enter it as a date in the dataset to mimic the real dataset.
How can I change the code to get what I want:
Regards,
BlueBlue
data mbrtest; Input Id EffeDate; format EffeData mmddyyyy10.; datalines; 1 12/11/2021 1 12/12/2021; Run; /*Date variable comes blank. How to resolve this issue? I have searched and I couldn't find any solution*/
data mbrtest; informat EffeDate mmddyy10.; format effeDate mmddyy10.; Input Id EffeDate; datalines; 1 12/11/2021 1 12/12/2021 ; Run;
@GN0001 wrote:
Hello team,
I need to create a dataset and I want to enter it as a date in the dataset to mimic the real dataset.
How can I change the code to get what I want:
Regards,
BlueBlue
data mbrtest; Input Id EffeDate; format EffeData mmddyyyy10.; datalines; 1 12/11/2021 1 12/12/2021; Run; /*Date variable comes blank. How to resolve this issue? I have searched and I couldn't find any solution*/
data mbrtest; informat EffeDate mmddyy10.; format effeDate mmddyy10.; Input Id EffeDate; datalines; 1 12/11/2021 1 12/12/2021 ; Run;
@GN0001 wrote:
Hello team,
I need to create a dataset and I want to enter it as a date in the dataset to mimic the real dataset.
How can I change the code to get what I want:
Regards,
BlueBlue
data mbrtest; Input Id EffeDate; format EffeData mmddyyyy10.; datalines; 1 12/11/2021 1 12/12/2021; Run; /*Date variable comes blank. How to resolve this issue? I have searched and I couldn't find any solution*/
The log should have told you most of the problems:
11 data mbrtest; 12 Input Id EffeDate; 13 format EffeData mmddyyyy10.; ----------- 484 NOTE 484-185: Format MMDDYYYY was not found or could not be loaded. 14 datalines; NOTE: Variable EffeData is uninitialized. NOTE: Invalid data for EffeDate in line 15 3-12. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+-- 15 1 12/11/2021 Id=1 EffeDate=. EffeData=. _ERROR_=1 _N_=1 NOTE: Invalid data for EffeDate in line 16 3-12. 16 1 12/12/2021 Id=1 EffeDate=. EffeData=. _ERROR_=1 _N_=2 NOTE: The data set WORK.MBRTEST has 2 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds 17 ; 18 Run;
First: do not place the ; at the end of datalines on a line with data, that causes an error.
Your code did not provide any instructions on how to read Effedate so SAS assumes it is a simple numeric value. The / in the value means the values are not simple numbers and generate invalid data messages.
The log tells you that the name of the Format you attempted to use is invalid. (Hint: None of the SAS supplied date formats/informats use YYYY in the name. Or at least I haven't see one yet.)
The note that Effedata is uninitialized should have been a clue that you have a spelling issue.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.