I have the following dataset where both 'Date' and 'Value' are in character format. I would like to convert Date from character to date field and Value from character to numeric using proc sql; command. I am unable to convert the Date
ID | Date | Value |
1 | 2020-01-01 | 1 |
2 | 2020-04-01 | 2 |
3 | 2020-05-09 | 1 |
4 | 2020-09-04 | 1 |
proc sql;
create table test as
select ID, input(Date, mmddyy10.) as DateNew format=mmddyy10.,
input(Value, best.) as Value
from have;
quit;
the Value is being converted properly but not Date. It shows an error that invalid or missing/error
</>
Invalid date value
NOTE: Invalid argument to function INPUT. Missing values may be generated.
Your strings are not in Month Day Year order like you told the INPUT() function they were.
Your strings are in Year Month Day order.
input(Date, yymmdd10.)
When you have code that is causing an error, SHOW US THE LOG. The entire log for PROC SQL, every single word, in the sequence that it appears, with nothing chopped out. Please format the log properly by clicking on the </> icon and pasting the log as text into the window that appears; this makes the log more readable (and I no longer try to read logs that aren't formatted this way).
I edited the text
</>
Invalid date value
NOTE: Invalid argument to function INPUT. Missing values may be generated.
@pacman94 wrote:
I edited the text
</>
Invalid date value
NOTE: Invalid argument to function INPUT. Missing values may be generated.
This is not the ENTIRE log for PROC SQL that I asked for, and it needs to be formatted properly, as I described. What you have provided is part of the log, detached from the rest of the log and detached from the code that created the error, is not useful.
I see . the original dates are in YYYY-MM-DD format. I tried different combinations . There are no missing dates
Your strings are not in Month Day Year order like you told the INPUT() function they were.
Your strings are in Year Month Day order.
input(Date, yymmdd10.)
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.