- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
hello everybody.
I want to convert date character type to numeric. I use a code which is shown below.
data Sampledata;
set table01 table02;
new_var = input(TRD_EVENT_DT,mmddyy10.);
format new_var date9.;
drop TRD_EVENT_DT;
rename new_var = TRD_EVENT_DT;
run;
The log file is:
NOTE: Invalid argument to function INPUT at line 938 column 15.
TRD_EVENT_DT=2014-03-25 TRD_EVENT_TM=11:36:35 TRD_STCK_CD=PNLZ1 TRD_PR=22200 TRD_TUROVR=2400 new_var=.
_ERROR_=1 _N_=1
NOTE: Invalid argument to function INPUT at line 938 column 15.
TRD_EVENT_DT=2014-03-25 TRD_EVENT_TM=11:37:17 TRD_STCK_CD=PNLZ1 TRD_PR=22210 TRD_TUROVR=50 new_var=.
_ERROR_=1 _N_=2
NOTE: Invalid argument to function INPUT at line 938 column 15.
TRD_EVENT_DT=2014-03-25 TRD_EVENT_TM=11:37:17 TRD_STCK_CD=PNLZ1 TRD_PR=22202 TRD_TUROVR=50 new_var=.
_ERROR_=1 _N_=3
NOTE: Invalid argument to function INPUT at line 938 column 15.
TRD_EVENT_DT=2014-03-25 TRD_EVENT_TM=11:38:09 TRD_STCK_CD=PNLZ1 TRD_PR=22230 TRD_TUROVR=500 new_var=.
_ERROR_=1 _N_=4
NOTE: Invalid argument to function INPUT at line 938 column 15.
TRD_EVENT_DT=2014-03-25 TRD_EVENT_TM=11:38:09 TRD_STCK_CD=PNLZ1 TRD_PR=22200 TRD_TUROVR=1434 new_var=.
_ERROR_=1 _N_=5
NOTE: Mathematical operations could not be performed at the following places. The results of the
operations have been set to missing values.
Each place is given by: (Number of times) at (Line):(Column).
17976342 at 938:15
NOTE: There were 10000000 observations read from the data set WORK.TABLE01.
NOTE: There were 7976342 observations read from the data set WORK.TABLE02.
NOTE: The data set WORK.SAMPLEDATA has 17976342 observations and 5 variables.
What is the problem?
How can I fix that?
Thanks in advance.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For starters your date looks like:
TRD_EVENT_DT=2014-03-25
While you've specified an informat of:
mmddyy10.
Which is month, day, year. Yours is clearly yymmdd
There's possibly other issues, but you should probably fix that first. I would remove the rename until it works and then do it after. It's usually easier and cleaner IMO to rename the variable on input, create the new variable with the old name and then drop the old variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For starters your date looks like:
TRD_EVENT_DT=2014-03-25
While you've specified an informat of:
mmddyy10.
Which is month, day, year. Yours is clearly yymmdd
There's possibly other issues, but you should probably fix that first. I would remove the rename until it works and then do it after. It's usually easier and cleaner IMO to rename the variable on input, create the new variable with the old name and then drop the old variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
use
new_var = input(myvar,yymmdd10.);
and do not forget to format as below or whatever you like
format new_var mmddyy10.;