<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: proc export in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-export/m-p/22914#M3763</link>
    <description>Cynthia,&lt;BR /&gt;
 Thanks for your help.I will try one of your suggested methods.&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
SASPhile</description>
    <pubDate>Mon, 27 Apr 2009 14:01:25 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2009-04-27T14:01:25Z</dc:date>
    <item>
      <title>proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export/m-p/22911#M3760</link>
      <description>Physician    product  year    scripts&lt;BR /&gt;
    Mark            Novo     2007  3000&lt;BR /&gt;
    Mark            Novo     2007  4000&lt;BR /&gt;
    Mark            Feib     2007  2500&lt;BR /&gt;
    Mark           Novo     2008   2500&lt;BR /&gt;
    Twain          Novo     2007  2000&lt;BR /&gt;
    Twain          Novo     2008  3000&lt;BR /&gt;
    Twain          Novo     2008  6000&lt;BR /&gt;
&lt;BR /&gt;
How to generate the above data to following way ?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
                           2007                    2008&lt;BR /&gt;
 Physician       Novo   Feib             Novo   Feib&lt;BR /&gt;
  Mark               7000   2500           2500      -&lt;BR /&gt;
  Twain              2000     -                9000      -</description>
      <pubDate>Thu, 23 Apr 2009 18:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export/m-p/22911#M3760</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-04-23T18:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export/m-p/22912#M3761</link>
      <description>Investigate SAS PROC TABULATE, or the SAS DATA step can generate such a formatted-output.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Report Creation Using Data _NULL_&lt;BR /&gt;
Caroline Bahler, Meridian Software, Inc., Raleigh NC&lt;BR /&gt;
Eric Brinsfield, Meridian Software, Inc., Raleigh NC&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi27/p061-27.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi27/p061-27.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Several search-matches using the Google advanced search argument below:&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate reporting site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website provides SAS-hosted documentation and technical / conference reference material suitable to your post topic.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sat, 25 Apr 2009 18:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export/m-p/22912#M3761</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-25T18:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export/m-p/22913#M3762</link>
      <description>Hi:&lt;BR /&gt;
  There's a difference between wanting to export a data set (which you would get with PROC EXPORT) and wanting a report (which you would get with PROC REPORT). The results of a report procedure could be routed to HTML, CSV, or other destinations. However, you can only use a dataset with PROC EXPORT.&lt;BR /&gt;
&lt;BR /&gt;
  When you used this same data with a question about PROC REPORT:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?threadID=5625&amp;amp;tstart=0" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?threadID=5625&amp;amp;tstart=0&lt;/A&gt; you seemed to want a report. Now you ask about an output dataset. Proc Export will not restructure or summarize your data from its original structure to the new structure that you show.&lt;BR /&gt;
&lt;BR /&gt;
If your data are in one structure and you need the -data- to be in another structure, then the tools at your disposal are PROC TRANSPOSE, DATA _NULL_, PROC SQL, etc.&lt;BR /&gt;
&lt;BR /&gt;
However, your example shows a summarization, as well as a simple restructuring of data. For example... your original data shows&lt;BR /&gt;
[pre]&lt;BR /&gt;
                     &lt;BR /&gt;
Physician product year scripts&lt;BR /&gt;
Mark      Novo    2007   3000&lt;BR /&gt;
Mark      Novo    2007   4000&lt;BR /&gt;
Mark      Feib    2007   2500&lt;BR /&gt;
Mark      Novo    2008   2500&lt;BR /&gt;
Twain     Novo    2007   2000&lt;BR /&gt;
Twain     Novo    2008   3000&lt;BR /&gt;
Twain     Novo    2008   6000&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                 &lt;BR /&gt;
while your desired output (report? dataset?) shows:&lt;BR /&gt;
[pre]&lt;BR /&gt;
             2007      2008&lt;BR /&gt;
Physician Novo Feib Novo Feib&lt;BR /&gt;
Mark      7000 2500 2500  -&lt;BR /&gt;
Twain     2000  -   9000  - &lt;BR /&gt;
                     &lt;BR /&gt;
[/pre]&lt;BR /&gt;
                               &lt;BR /&gt;
To me, the above still looks like an output REPORT, because you show each year -above- each drug name, in a more report-like fashion, and you show a dash &lt;BR /&gt;
(-) instead of a .or a 0 for years when there were no scripts. &lt;BR /&gt;
&lt;BR /&gt;
I would expect that an output DATASET would be structured and have variable names like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Physician Novo2007 Feib2007 Novo2008 Feib2008&lt;BR /&gt;
Mark      7000     2500       2500     .&lt;BR /&gt;
Twain     2000       .        9000     . &lt;BR /&gt;
                                    &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
If you want a REPORT showing the physician names going down the rows and then showing years and products going across the columns, your choices for a report are to use either PROC REPORT or PROC TABULATE. You could use PROC MEANS and then transpose, but either REPORT or TABULATE will give you a summary report in the structure you want.&lt;BR /&gt;
&lt;BR /&gt;
If you want an output dataset, you still have the above tools at your disposal. You also have the ability to create output datasets from PROC REPORT and PROC TABULATE. However, you may find that the output datasets are not quite in the structure or have the variables named as you might want.&lt;BR /&gt;
&lt;BR /&gt;
The code below shows you some REPORT or TABULATE code to generate a report. Each step creates an output dataset. At the bottom of the two steps are PROC PRINTS of the output dataset created by each procedure. Either of these datasets (WORK.TABOUT or WORK.REPOUT could be exported with PROC EXPORT.) Or, since you can route your PROC REPORT or PROC TABULATE output to an HTML file, an RTF file, a PDF file, a CSV file or an Excel Spreadsheet Markup Language file, you may discover that you don't need PROC EXPORT, at all.&lt;BR /&gt;
        &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data phys;&lt;BR /&gt;
  length Physician $16 Product 	$20;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input Physician $ product $ year scripts ;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines; &lt;BR /&gt;
Mark Novo 2007 3000&lt;BR /&gt;
Mark Novo 2007 4000&lt;BR /&gt;
Mark Feib 2007 2500&lt;BR /&gt;
Mark Novo 2008 2500&lt;BR /&gt;
Twain Novo 2007 2000&lt;BR /&gt;
Twain Novo 2008 3000&lt;BR /&gt;
Twain Novo 2008 6000&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                                     &lt;BR /&gt;
options nodate missing=0; &lt;BR /&gt;
&lt;BR /&gt;
** Without using PROC EXPORT, use ODS to create files that can be;&lt;BR /&gt;
** opened and rendered with different programs:;&lt;BR /&gt;
** File   Created with       Open with                                 ;&lt;BR /&gt;
** HTML  ODS MSOFFICE2K      Internet Explorer, Word or Excel          ;&lt;BR /&gt;
** CSV   ODS CSVALL          Excel or Lotus or any pgm that reads CSV  ;&lt;BR /&gt;
** RTF   ODS RTF             Word or any word processor                ;&lt;BR /&gt;
** PDF   ODS PDF             Acrobat Reader or any PDF-viewer          ;&lt;BR /&gt;
** XML   ODS TAGSETS.EXCELXP Excel 2002 or higher  Note that type of   ;&lt;BR /&gt;
**                           XML created conforms to Excel 2002/2003   ;&lt;BR /&gt;
**                           Spreadsheet Markup Language specification ;&lt;BR /&gt;
**;&lt;BR /&gt;
              &lt;BR /&gt;
ods msoffice2k file='c:\temp\physreport_ht.html' style=sasweb;&lt;BR /&gt;
                                   &lt;BR /&gt;
ods rtf file='c:\temp\physreport_wp.rtf';&lt;BR /&gt;
   &lt;BR /&gt;
ods pdf file='c:\temp\physreport_ar.pdf';&lt;BR /&gt;
   &lt;BR /&gt;
ods csvall file='c:\temp\physreport_plain.csv' style=sasweb;&lt;BR /&gt;
                                  &lt;BR /&gt;
ods tagsets.excelxp file='c:\temp\physreport_xp.xls' &lt;BR /&gt;
    options(embedded_titles='yes' absolute_column_width='10')&lt;BR /&gt;
    style=sasweb;&lt;BR /&gt;
          &lt;BR /&gt;
ods tagsets.excelxp options(sheet_name='Tabulate');&lt;BR /&gt;
proc tabulate data=phys f=comma8.&lt;BR /&gt;
      out=work.tabout;&lt;BR /&gt;
  title 'Report with PROC TABULATE';&lt;BR /&gt;
  class physician product year;&lt;BR /&gt;
  var scripts;&lt;BR /&gt;
  table physician=' ',&lt;BR /&gt;
        year='Scripts Per Year'*product=' '*scripts=' ' &lt;BR /&gt;
       / box={label=Physician style={vjust=b}} row=float printmiss;&lt;BR /&gt;
  keylabel sum=' ';&lt;BR /&gt;
run;&lt;BR /&gt;
        &lt;BR /&gt;
ods tagsets.excelxp options(sheet_name='Report'); &lt;BR /&gt;
proc report data=phys nowd&lt;BR /&gt;
  out=work.repout(rename=(_c2_=Feib2007 _c3_=Novo2007 _c4_=Feib2008 _c5_=Novo2008));&lt;BR /&gt;
  title 'Report with PROC REPORT';&lt;BR /&gt;
  column physician scripts,year,product;&lt;BR /&gt;
  define physician / group style(column)=Header;&lt;BR /&gt;
  define year / across ' ';&lt;BR /&gt;
  define product / across ' ';&lt;BR /&gt;
  define scripts / sum 'Scripts Per Year' f=comma8.;&lt;BR /&gt;
run;&lt;BR /&gt;
ods _all_ close;&lt;BR /&gt;
                                   &lt;BR /&gt;
** if none of the above output files are satisfactory, then you can;&lt;BR /&gt;
** export either of these 2 files, created from the above procedures.;&lt;BR /&gt;
ods html file='c:\temp\data_from_report_proc.html' &lt;BR /&gt;
         style=sasweb;&lt;BR /&gt;
                                 &lt;BR /&gt;
proc print data=work.tabout;&lt;BR /&gt;
  title 'Data set created by PROC TAB';&lt;BR /&gt;
  title2 'Would still need to transpose this before Export';&lt;BR /&gt;
run;&lt;BR /&gt;
                                             &lt;BR /&gt;
proc print data=work.repout;&lt;BR /&gt;
  title 'Data set created by PROC REPORT';&lt;BR /&gt;
  title2 'This could be Exported as it is';&lt;BR /&gt;
run;&lt;BR /&gt;
                                            &lt;BR /&gt;
ods _all_ close;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sat, 25 Apr 2009 21:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export/m-p/22913#M3762</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-04-25T21:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export/m-p/22914#M3763</link>
      <description>Cynthia,&lt;BR /&gt;
 Thanks for your help.I will try one of your suggested methods.&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
SASPhile</description>
      <pubDate>Mon, 27 Apr 2009 14:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export/m-p/22914#M3763</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-04-27T14:01:25Z</dc:date>
    </item>
  </channel>
</rss>

