BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tejaswini3
Obsidian | Level 7

Kindly check below code

data PKMERGE;
set PKDAR;
/*Derivation of elapsed time*/
/*Join date and time*/
datetime=dhms(input(ATLSMP1T, date9.), 0, 0, input(ATLSMP1T, 11.));
run;

After running above code following log is appearing

NOTE: Invalid argument to function INPUT at line 738 column 15.
NOTE: Invalid argument to function INPUT at line 738 column 46.

Because of this datetime value is not able to generate. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tejaswini3
Obsidian | Level 7

The code need to be

data trial;
set pkmerge;
datetime=dhms(input(SMP1D, date9.), 0, 0, input(ATLSMP1T, time5.));
run;

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

You get this message because the values of variable ATLSMP1T cannot be properly used in the INPUT function with the format shown.

 

So what are typical values of this variable? Best to show us a portion of your data set named PKDAR as SAS data step code (instructions) and not in any other format.

--
Paige Miller
Tejaswini3
Obsidian | Level 7

Kindly see the below image for the input column

 

Tejaswini3_0-1646485794653.png

 

ballardw
Super User

Run Proc Contents on that data set and show us the variable properties.

Or click on the column heading of the variable in the VIEWTABLE window, which will bring up variable properties. Show us the type and assigned format.

If the type is Numeric and the Format is Date9. then the input is failing because the value is numeric and a date and does not need to be input. Same if the time variable is numeric with a Time format, it is already time and does not need input.

Tejaswini3
Obsidian | Level 7

The photo for DOB1D

Tejaswini3_0-1646494614879.png

 

The photo for VSN1D

Tejaswini3_1-1646494672099.png

 

Tom
Super User Tom
Super User

Looking at the pictures you posted the values of the time variable it has a colon in it. Hence the error when trying to read it as a number.  You  will want to use the TIME informat to convert strings like '11:12' into a time value (number of seconds since midnight).

 

datetime=dhms(input(ATLSMP1T, date9.), 0, 0, input(ATLSMP1T, time9.));

 

(I really don't understand why people go to the extra effort to take pictures of text and jump through hoops to post them instead of just copying and pasting the text. or in the case of the types and lengths of 2 variables just typing the text directly)

Tejaswini3
Obsidian | Level 7

Still same issue is coming

 

 

NOTE: Invalid argument to function INPUT at line 134 column 15.
NOTE: Invalid argument to function INPUT at line 134 column 46.
ATLSMP1T=10:55 SMP1D=13MAR2006 datetime=. _ERROR_=1 _N_=1

 

 

Tejaswini3
Obsidian | Level 7

The code need to be

data trial;
set pkmerge;
datetime=dhms(input(SMP1D, date9.), 0, 0, input(ATLSMP1T, time5.));
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 968 views
  • 2 likes
  • 4 in conversation