Hello all,
I have been having issues converting date ths is in yymmdd10. to ddmmyy10.
I have been trying this code
, input(LVRTEDAT,yymmdd10.) as LVRTEDAT format ddmmyy10.
, input(LVPURDAT,yymmdd10.) as LVPURDAT format ddmmyy10.
ERROR: INPUT function requires a character argument.
ERROR: Character expression requires a character format.
ERROR: INPUT function requires a character argument.
ERROR: Character expression requires a character format.
LVTREDAT is a variable pulling from sql which is in yymmdd10.
I have also tried the below code and coming up with the below error
format LVINPDAT ddmmyy10.;
format LVRTEDAT ddmmyy10.;
format LVPURDAT ddmmyy10.;
ERROR: CLI cursor fetch error: [Microsoft][SQL Server Native Client 11.0]Numeric value out of range
FULL ACTUAL CODE:
proc sql exec;
connect to odbc (&connectA);
create table pveh as
select
LVPOLNO
, LVVEHNO
, LVVEHPRM
, LVVEHPRC
, LV1SPR2A
, LVALWDRV
, LVPLNNO
, LVNCD
, LVRGDPRS
, LVBASEXS
, LVADDEXS
, input(LVINPDAT,yymmdd10.) as LVINPDAT format ddmmyy10.
, input(LVRTEDAT,yymmdd10.) as LVRTEDAT format ddmmyy10.
, input(LVPURDAT,yymmdd10.) as LVPURDAT format ddmmyy10.
, LVNCDPRO
, LVCVRTYP
, LVUSECDE
, LVINSVAL
, LVVEHMOD
, LVVEHBDY
, LVCHPFCT
, LVVEHYRL
, LV1SPR7P0
, LVANNMLG
, LVBRKCVR
, LVLGLPRO
, LV2SPR1A
, LVMOPCDE
from connection to odbc
(select * from OPENQUERY
(BETA,'
Select
*
from
budadm.pveh as A
where
a.lVpolno >= '&min'
and a.lVpolno <= '&max'
and a.lVamdno = 1
')A)B;
disconnect from odbc;
quit;
run;
Your help will be much appreciated. Thanks 🙂
Your code look fine.
Could you select some rows without formating from these columns and post them here?
Here are the unformatted columns. They are in date9. format. changed the format in the input statement and that's not working either
I do not understand your dates are already saved in which format date9. or yymmdd10 ???
Macro variables e.g. &min need to be within double quotes to be dereferenced, e.g.:
a.lVpolno >= "&min"
What is it your doing, it looks like your passing a query through to a database? Until your familiar with doing such a thing, just select * from table, get the data back to SAS and then process it. If you want a response on your original question, do the above, get the data to SAS, and then post of proc contents of the retrieved data, and example of what it looks like. Its likely you will get ISO dates, or date/times back from the database.
Hi,
Try this way...
input(put(LVRTEDAT,10.),yymmdd10.)) as LVRTEDAT format ddmmyy10.
, input(put(LVPURDAT,10.),yymmdd10.)) as LVPURDAT format ddmmyy10.
Thanks,
Bharath
Have you tried simplifying the code:
, LVINPDAT format ddmmyy10.
The variable already has the proper value, you just need to change the format.
Since you are getting a message about values out of range, it is conceivable that you have a date-time variable and need to extract the date part:
, datepart(lvinpdat) as lvinpdat format ddmmyy10.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.