I'm told if i wrap variable in an input statement it will convert it to sas datetime, can anyone provide example?
create table Total_CallsHandled_by_Day as
select datepart(ReportTime), sum(agentcallshandled) as Calls_Handled
251 proc sql;
252 create table Total_CallsHandled_by_Day as
253 select datepart(ReportTime), sum(agentcallshandled) as Calls_Handled
254 from ccar_callshandled;
ERROR: Function DATEPART requires a numeric expression as argument 1.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
which has specific information - you are referencing a CHARACTER type variable ReportTime which you must first convert to a NUMERIC (SAS DATETIME type) variable using the INPUT(,) function in your SELECT statement.
As someone had mentioned in the last thread your reporttime variable is stored as a character rather than a date.
If you create a new variable with the proper format then you will no longer have this issues. Basically, if you don't fix this issue, you'll have a lot of issues working with the variable trying to calculate durations, or comparing to other dates or formatting to other date time formats...I could go on.
Its bad programming, fix it in the initial data creation/import step if possible.
wrong='2010-09-30 00:00:00.000000'; *this is what you have;
correct=input(wrong, anydtdtm22.); *this converts it to datetime variable;
format correct datetime18.;
Given all the information and feedback, you chose to treat the "symptom" rather than solving the problem (by changing your literal string -- hoping that a left-to-right byte comparison will still work), which in-turn created another challenge in your variable SELECT -- that is my point. Had you addressed the "character string date-time" problem and converted the variable on input to a SAS numeric-type DATETIME variable, then you would not have needed to register this post.
Scott i am just doing the best i can, I searched google advance and web forum as you suggested without coming up with an example i could understand.
I asked several times if you could provide an example but you just kept telling me the same thing.
I would like to do things correctly, that of course is what i want.
What does register post mean?
Message was edited by: fredbell
Reeza has provided an example that seems to do what you are mentioning, correct?
You really need to get a clear understanding about your external data representation, specifically that you are working with a character-string of data that appears as a date-time. And within SAS, you must convert that string to a SAS numeric DATETIME (or DATE) variable value, so that SAS functions can operate on the resulting numeric value (represented as either a datetime value ( "seconds since 1/1/1960") or a date value ("days since 1/1/1960").
The SAS Language Dictionary and SAS Language Concepts guides each have reference material on this topic, and also the SAS support website has technical / conference papers on the topic.
Until you devote time to self-initiated review and attention, these facilities will continue to course you have suggested.