Data visualization with SAS programming

pie charts

Accepted Solution Solved
Reply
Super Contributor
Super Contributor
Posts: 435
Accepted Solution

pie charts

hi guys,

i need to export pie charts from SAS into an excel file.Can anyone please share a nice code for resizing charts and exporting them to excel?

Is there also a  macro code that would export the charts to a certain spot of the excel worksheet? Smiley Happy

Thanks,


Accepted Solutions
Solution
‎01-30-2013 05:22 PM
Grand Advisor
Posts: 17,351

Re: pie charts

If you called the named range pie_chart for example use that as your sheet name.

PROC EXPORT DATA= work.scores

  OUTFILE= 'C:\excel files\class.xls'

  DBMS=EXCEL REPLACE;

  SHEET="pie_chart";

RUN;

20923 - How REPLACE option works with PROC EXPORT and Excel files in SAS 9.1

View solution in original post


All Replies
Grand Advisor
Posts: 17,351

Re: pie charts

I don't think there's an easy way to export a graphic to Excel. You can using ods HTML, but then your file is HTML not really Excel.

Is this a brand new excel sheet or a sheet with data in it already?

I would recommend creating the chart in Excel and then feeding the data from SAS.

Super Contributor
Super Contributor
Posts: 435

Re: pie charts

The sheet has  tables which automatically populate from the data imported  into excel from SAS.Next to each table i am supposed to have  a chart designed based on the data coming from SAS.So i have 5 tabs,one with the tables and 4 tabs with data coming from SAS.So,as data  would be coming from SAS those charts will be updated in each of the tabs and  then i manually move them in the first tab next to the tables.Is there a way maybe i can link the  charts from the 1st tab to the charts in each of the other 4 tabs so the ones in the 1st tab get updated along with the ones in the other 4  tabs? Probably SAS cant do this as you yourself said it. 

Super Contributor
Super Contributor
Posts: 435

Re: pie charts

but then i wont be able to feed those  tabs with new data from SAS if i already have charts on them,right?

Grand Advisor
Posts: 17,351

Re: pie charts

I totally don't understand. The chart can be anywhere in the work book and link to sheets that SAS is updating. You shouldn't need to 'move' anything.

SAS can update a tab with new information if you create a named range in the template before hand and then write to that specifically.

Super Contributor
Super Contributor
Posts: 435

Re: pie charts

so probably linking the charts to the data coming from sas can be done with excel macro?

Grand Advisor
Posts: 17,351

Re: pie charts

Make a chart that is linked to a table in Excel.

Highlight the data and create a named range.

Make your export data fit the named range exactly (same column names, formatting etc)

Output your excel data to the named range (using proc export with replace option or the libname method by first dropping the table and then recreating it).

Open the excel file and the chart will show the new data.

Super Contributor
Super Contributor
Posts: 435

Re: pie charts

sorry but how do i output the data to the named range,i mean how do i link proc export to the named  range? Smiley Happy

Solution
‎01-30-2013 05:22 PM
Grand Advisor
Posts: 17,351

Re: pie charts

If you called the named range pie_chart for example use that as your sheet name.

PROC EXPORT DATA= work.scores

  OUTFILE= 'C:\excel files\class.xls'

  DBMS=EXCEL REPLACE;

  SHEET="pie_chart";

RUN;

20923 - How REPLACE option works with PROC EXPORT and Excel files in SAS 9.1

Super Contributor
Super Contributor
Posts: 435

Re: pie charts

thanks Reeza.this is actually working.Thanks again

Super Contributor
Posts: 578

Re: pie charts

I think the suggested approach for this is to use the SAS Add-in for Office.  Its a simple matter to then link the SAS Data range to the chart.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 624 views
  • 1 like
  • 3 in conversation