I am new to DS2. I am trying to convert string "10/31/2011 1:34:00 PM", passed through "time" variable, to SAS date value to be used in SAS ESP.
However when I run it in ESP I get the error below
"load project failed: tradesDemo, the input function requires 0 parameter(s)"
ds2_options cdump;
data esp.out;
dcl timestamp datetime;
method run();
set esp.in;
datetime = input(time, mmddyy10.);
format datetime mmddyy10.;
end;
enddata;
@arkam wrote:
I am new to DS2. I am trying to convert string "10/31/2011 1:34:00 PM", passed through "time" variable, to SAS date value to be used in SAS ESP.
However when I run it in ESP I get the error below
"load project failed: tradesDemo, the input function requires 0 parameter(s)"
ds2_options cdump;
data esp.out;
dcl timestamp datetime;
method run();
set esp.in;
datetime = input(time, mmddyy10.);
format datetime mmddyy10.;
end;
enddata;
If you do not attempt any operation on the variable time what type is the resulting variable and what format does it have? Not what it looks like in the source data system but as reported by SAS tools on the result data set.
In general the INPUT function takes a character value. If time is actually numeric then that is one possible problem.
I will also say that apparently wanting only the date part of value but calling it "datetime" is likely to be a source of confusion in the future.
It is type string and this is the format which is displayed in SAS stream viewer
10/31/2011 13:34
I want both the date and the time to aggregate on.
@arkam wrote:
It is type string and this is the format which is displayed in SAS stream viewer
10/31/2011 13:34
I want both the date and the time to aggregate on.
I don't have a lot of experience with DS2 and no data sources to actually connect to but from the documentation:
How to Specify Informats in DS2
In DS2, specify informats as an attribute in the HAVING clause of the DECLARE statement. For example, in the following statement, the column y is declared with the IEEE8.2 format and the BITS5.2 informat.dcl double y having format ieee8.2 informat bits5.2;
So that is why I think you get the message out input not wanting any parameters and that just applying the informat as above does the conversion.
I would suggest getting a datetime value from the string and then pulling the bits out using the DATEPART and TIMPART functions once you have the datetime variable populated.
The following creates a SAS datetime value from that sort of string value so is the likely informat to specify on the DCL statement.
data example; x='10/31/2011 13:34'; y= input(x, anydtdtm.); format y datetime18.; run;
So using the
Does the INPUT function work in DS2? It doesn't work with %SYSFUNC(). There you need to use INPUTN() or INPUTC() depending on the target value type.
datetime = inputN(time, 'mmddyy10.');
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.