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

SAS newbie here--I am putting together an Excel spreadsheet via the ods tagsets.excelxp method. I have been searching online, but I have not yet found a way to display a datetime in a way that Excel would recognize as a datetime. My Excel spreadsheet currently displays (for example) 06JAN2015:07:39:37, when ideally, I would like it to read 01/06/2015 07:39 (24-hr format). Is there a datetime format that would allow me to do this? If not, what is the best way to go about this? I stumbled upon datepart and timepart functions, so the best I can think of for now is to concatenate those together, but I would be interested to know if there are other methods out there. Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Here is an old note explaining about using the TAGATTR feature to tell Excel how to format the dates.

38143 - Apply date formats with the ExcelXP destination

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

Here is an old note explaining about using the TAGATTR feature to tell Excel how to format the dates.

38143 - Apply date formats with the ExcelXP destination

kgot
Fluorite | Level 6

Thank you, Tom--that worked perfectly for my proc print statements. I am only having difficulty with a proc report--it does not seem that tagattr is an option for that--is there a way to do the same thing in a proc report?

Thanks again!

ballardw
Super User

Here's an example of proc report and tagattr.

proc report data=sashelp.shoes(obs=10) nowd ;

  title 'Using tagattr and TAGSETS.EXCELXP';

  title2 'Send a Formula for a Column';

  column region product sales profit;

  define region/display;

  define product /display;

  define sales/ sum 'Sales'   

      style(column)={tagattr="$###,##0.00"};

  define profit / computed "Profit"

            style(column)=

           {tagattr='Formula:RC[-1]*0.9'};

  compute profit;

    ** profit is not in sashelp.shoes;

    ** so make an empty column for the formula;

    profit = 0;

  endcomp;

run;

kgot
Fluorite | Level 6

Got it--that worked! I was trying to use just "style" instead of "style(column)"--once I changed that, it worked perfectly.

Thank you to both of you--I really appreciate it!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2216 views
  • 5 likes
  • 3 in conversation