Discussion:
Percent format lost after exporting to excel
(too old to reply)
David Fickbohm
2005-07-15 21:57:48 UTC
Permalink
People,
I calculated three percentages. Then formatted then and exported them to excel. The formatting looks great in the sas file prior to exporting. In excel the formatting is gone.

Is there a way to retain the formatting ?
data county_out;
set county_data_sumd;
pct_highschool_grads = (total_hs_grads / county_tot_pop);
run;
data final;
format pct_highschool_grads percent5. ;
run;

proc export final;
outfile = 't:\dave\demographic\out\county_&sysdate..xls'
dbms = excel2000 replace;
run;

In sas datasets before exporting
pct_highschool_grads --- 23%

in excel after exporting
.2345435

If this is not possible it is OK, someone please tell me it can not be done and the client will be happy. I can multiply the resulting percent by 100 and round to get 23 That will be fine with the client.

all help will be greately appreciated.




Dave Fickbohm
Use Technology to the Fullest
1250 45th st suite 200
Emeryville, CA, 94608
510 594 4151 voice

---------------------------------
Yahoo! Mail for Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
Choate,
2005-07-15 22:15:59 UTC
Permalink
Hi David -

There are a lot of ways to skin that cat. Unfortunately formats and labels
don't get exported to Excel.

If you want to stick with export then creating a character variable might be
easiest:

pct_highschool_grads = put(total_hs_grads/county_tot_pop,percent6.);

Otherwise ODS can send formatted data to Excel or DDE can run a macro to
format data once it's in Excel.

hth

Paul Choate
DDS Data Extraction
(916) 654-2160

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU] On Behalf Of David
Fickbohm
Sent: Friday, July 15, 2005 2:58 PM
To: SAS-***@LISTSERV.UGA.EDU
Subject: Percent format lost after exporting to excel

People,
I calculated three percentages. Then formatted then and exported them to
excel. The formatting looks great in the sas file prior to exporting. In
excel the formatting is gone.

Is there a way to retain the formatting ?
data county_out;
set county_data_sumd;
pct_highschool_grads = (total_hs_grads / county_tot_pop);
run;
data final;
format pct_highschool_grads percent5. ;
run;

proc export final;
outfile = 't:\dave\demographic\out\county_&sysdate..xls'
dbms = excel2000 replace;
run;

In sas datasets before exporting
pct_highschool_grads --- 23%

in excel after exporting
.2345435

If this is not possible it is OK, someone please tell me it can not be done
and the client will be happy. I can multiply the resulting percent by 100
and round to get 23 That will be fine with the client.

all help will be greately appreciated.




Dave Fickbohm
Use Technology to the Fullest
1250 45th st suite 200
Emeryville, CA, 94608
510 594 4151 voice

---------------------------------
Yahoo! Mail for Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
Alan Churchill
2005-07-16 04:55:13 UTC
Permalink
...or XML handles it directly but you roll your own on the SAS side...

Thanks,
Alan

Savian
"Bridging SAS and Microsoft Technologies"
http://www.savian.net


-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU] On Behalf Of Choate,
***@DDS
Sent: Friday, July 15, 2005 3:16 PM
To: SAS-***@LISTSERV.UGA.EDU
Subject: Re: Percent format lost after exporting to excel

Hi David -

There are a lot of ways to skin that cat. Unfortunately formats and labels
don't get exported to Excel.

If you want to stick with export then creating a character variable might be
easiest:

pct_highschool_grads = put(total_hs_grads/county_tot_pop,percent6.);

Otherwise ODS can send formatted data to Excel or DDE can run a macro to
format data once it's in Excel.

hth

Paul Choate
DDS Data Extraction
(916) 654-2160

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU] On Behalf Of David
Fickbohm
Sent: Friday, July 15, 2005 2:58 PM
To: SAS-***@LISTSERV.UGA.EDU
Subject: Percent format lost after exporting to excel

People,
I calculated three percentages. Then formatted then and exported them to
excel. The formatting looks great in the sas file prior to exporting. In
excel the formatting is gone.

Is there a way to retain the formatting ?
data county_out;
set county_data_sumd;
pct_highschool_grads = (total_hs_grads / county_tot_pop);
run;
data final;
format pct_highschool_grads percent5. ;
run;

proc export final;
outfile = 't:\dave\demographic\out\county_&sysdate..xls'
dbms = excel2000 replace;
run;

In sas datasets before exporting
pct_highschool_grads --- 23%

in excel after exporting
.2345435

If this is not possible it is OK, someone please tell me it can not be done
and the client will be happy. I can multiply the resulting percent by 100
and round to get 23 That will be fine with the client.

all help will be greately appreciated.




Dave Fickbohm
Use Technology to the Fullest
1250 45th st suite 200
Emeryville, CA, 94608
510 594 4151 voice

---------------------------------
Yahoo! Mail for Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.

Loading...