Help using Base SAS procedures

Help exporting correct format

Reply
Occasional Contributor
Posts: 19

Help exporting correct format

Hi,

I am using the following to reformat some data from 9999 to 163-KN9-999:

proc format;

  picture KH_Format

  low-high='9-999'

  (prefix='163-KH');

run;

This gives me exactly what I need and the variables look great when I export to .csv.  Problem is that I need to export to .xlsx and the format does not "stick."  In the .xlsx file the formats go back to only a 4 digit rather than the desired 163-KH9-999.

Any thoughts on why this is or ideas on another method that will not cause problems?

Thank!

G

Super Contributor
Posts: 543

Re: Help exporting correct format

You could try the

ODS TAGSETS.EXCELXP and PROC PRINT

Anca.

Super User
Posts: 17,784

Re: Help exporting correct format

In the log SAS tells you that exporting to Excel will not maintain formats.

You have two options:

1) create a new variable and recode the variable using a put statement and output that variable instead.

2) Output using another destination, principally, tagsets.excelxp that will maintain the format.

Respected Advisor
Posts: 3,777

Re: Help exporting correct format

I think you will need to create a character version of the variable and export it insead of the numeric.

put(x,KH_FORMAT.)

Ask a Question
Discussion stats
  • 3 replies
  • 153 views
  • 0 likes
  • 4 in conversation