- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ok, this will work. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!