I'm not sure what the problem is, as you didn't share a portion of your real data with us. Please do that, following these examples and instructions.
As things stand now, I cannot reproduce this problem.
data fake;
occ_time='01JAN2024:00:00:00'dt; output;
occ_time='01JAN2024:01:15:00'dt; output;
format occ_time datetime.;
run;
proc transpose data=fake out=transp prefix=occ_name_;
var occ_time;
run;
Produces this output
Thank you for your response.
The original dataset looks like this:
The wanted/new dataset looks like this:
But I want the "Occ-Time" is still as "DATETIME." format rather than numbers.
Thank you!
Your code looks correct. Here is an example you can run for yourself.
data have;
do now=datetime(),datetime()+'24:00:00't ;
output;
end;
run;
proc print;
run;
proc transpose data=have out=want1 ;
var now;
run;
proc print;
run;
proc transpose data=have out=want2 ;
var now;
format now datetime19.;
run;
proc print;
run;
But perhaps the variable names are not what you think they are?
Your picture seems to have two columns with a header of OCC_TIME.
Which one did you use when you created the variable named OCC_TIME you used in your SAS code? What format did it have attached to it?
Thank you!
What happens if in PROC TRANSPOSE you use
proc transpose data=el.OCC out=el.wide prefix=Occ_Name_;
by UserName_numbers RecallNo;
var Occ_Time ;
run;
Ok, this will work. Thank you!
Actually in SAS your starting data cannot appear as shown as you show two variables named OCC_time and SAS will not allow that in a single data set. One of those is apparently a TIME value and the other a DATETIME value. If you transpose data so that both values end up in the same variable then you have a mix of time and datetime values in the variable and which ever format is attempted will display one of the values incorrectly.
@knighsson wrote:
Thank you for your response.
The original dataset looks like this:
The wanted/new dataset looks like this:
But I want the "Occ-Time" is still as "DATETIME." format rather than numbers.
Thank you!
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.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.