Formatted Datetimestamps from TODSTAMPw. Informat Not Correct
Formatted Datetimestamps from TODSTAMPw. Informat Not Correct
(OP)
I'm having some problems writing out a timestamp field. The format that I was aiming for was YYYY-MM-DD-HH:MM:SS.ssssss.
The informat used to read in the data was TODSTAMP4.. Here are some samples of my output using a PUT statement:
Can anyone suggest how to get the format into YYYY-MM-DD-HH:MM:SS.ssssss?
Thanks in advance!
The informat used to read in the data was TODSTAMP4.. Here are some samples of my output using a PUT statement:
CODE
NO FORMAT DATETIME23.6 TIME12. YYMMDD10.
1586273562.1 07APR10:15:32:42.148864 440631:32:42 **********
1583555017.7 07MAR10:04:23:37.719808 439876:23:38 **********
1584883864.5 22MAR10:13:31:04.453120 440245:31:04 **********
1583945561.9 11MAR10:16:52:41.948160 439984:52:42 **********
1588176606 29APR10:16:10:05.954048 441160:10:06 **********
1584637555 19MAR10:17:05:54.999296 440177:05:55 **********
1588271341.6 30APR10:18:29:01.649920 441186:29:02 **********
1588708670.2 05MAY10:19:57:50.193664 441307:57:50 **********
1584465774.1 17MAR10:17:22:54.133248 440129:22:54 **********
1586273562.1 07APR10:15:32:42.148864 440631:32:42 **********
1583555017.7 07MAR10:04:23:37.719808 439876:23:38 **********
1584883864.5 22MAR10:13:31:04.453120 440245:31:04 **********
1583945561.9 11MAR10:16:52:41.948160 439984:52:42 **********
1588176606 29APR10:16:10:05.954048 441160:10:06 **********
1584637555 19MAR10:17:05:54.999296 440177:05:55 **********
1588271341.6 30APR10:18:29:01.649920 441186:29:02 **********
1588708670.2 05MAY10:19:57:50.193664 441307:57:50 **********
1584465774.1 17MAR10:17:22:54.133248 440129:22:54 **********
Can anyone suggest how to get the format into YYYY-MM-DD-HH:MM:SS.ssssss?
Thanks in advance!
RE: Formatted Datetimestamps from TODSTAMPw. Informat Not Correct
Here is how:
CODE
x=datetime();*** or any datetime value ***;
y=put(datepart(x),yymmdd10.);
z=put(timepart(x),time16.6);
newtime=trim(y)||'-'||trim(left(z));
put x= y= z= newtime=;
run;
Hope this helps you.
Klaz
RE: Formatted Datetimestamps from TODSTAMPw. Informat Not Correct
I will give this a try. Can you offer any insight as to why when using the YYMMDD10. format the data is displayed with all asterisks?
Thank you again!
KS
RE: Formatted Datetimestamps from TODSTAMPw. Informat Not Correct
CODE
format y yymmdd10.;
Klaz
RE: Formatted Datetimestamps from TODSTAMPw. Informat Not Correct
RE: Formatted Datetimestamps from TODSTAMPw. Informat Not Correct
CODE
2 DATA R001;
3 INFILE INPUT1;
4 FILE SYSOUT;
5
6 INPUT @01 RECTYP $CHAR1. @ ;
7 IF RECTYP = '1' THEN
8 DO;
9 INPUT @73 ED_200_BASE1_EFF_DATE TODSTAMP4.;
10 END;
11
12 X=DATETIME(ED_200_BASE1_EFF_DATE);
________
________
________
72
72
72
ERROR 72-185: The DATETIME function call has too many arguments.
ERROR 72-185: The DATETIME function call has too many arguments.
ERROR 72-185: The DATETIME function call has too many arguments.
I assumed hte DATETIME function would be used on the variable I'm reading it. I checked the Language Dictionary and it indicates that I may need to only use the () to grab the current time. Is this correct? If so, how would I get the value from my input variable?
Any suggestions?
Thank you again!
ks
RE: Formatted Datetimestamps from TODSTAMPw. Informat Not Correct
CODE
Z=PUT(TIMEPART(ED_200_BASE1_EFF_DATE),TIME16.6);
IF HOUR(ED_200_BASE1_EFF_DATE) LT 10 THEN SUBSTR(Z,1,1) = '0';
ED_200_BASE1_EFF_DATE_C=TRIM(Y)||'-'||TRIM(LEFT(Z));
PUT Y= Z= ED_200_BASE1_EFF_DATE_C= ;
I added an IF statement since I need the hour to be a two-digit number. However, I'm getting a space between my hour digits:
CODE
Would you have a suggestion on where I can get rid of this space?
ks
RE: Formatted Datetimestamps from TODSTAMPw. Informat Not Correct
I presume that you will have a SAS datetime value to work with. Well then use the ISO 8601 format for date and time..
CODE
'x' is your datetime value and I use the TRANSLATE function to swap the ISO's standard 'T' sepparator for your '-' (hyphen requirement)
Good luck!
Klaz