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.
The code need to be
data trial;
set pkmerge;
datetime=dhms(input(SMP1D, date9.), 0, 0, input(ATLSMP1T, time5.));
run;
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.
Kindly see the below image for the input column
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.
The photo for DOB1D
The photo for VSN1D
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)
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
The code need to be
data trial;
set pkmerge;
datetime=dhms(input(SMP1D, date9.), 0, 0, input(ATLSMP1T, time5.));
run;
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!
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.