BookmarkSubscribeRSS Feed
arkam
Calcite | Level 5

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;

 

 

4 REPLIES 4
ballardw
Super User

@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.

arkam
Calcite | Level 5

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.

ballardw
Super User

@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

Tom
Super User Tom
Super User

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.');

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1533 views
  • 0 likes
  • 3 in conversation