<?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: strange way of doing export in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499404#M132890</link>
    <description>&lt;P&gt;Looks a lot like code taken initially from the log of a proc export run. Use of _EFIERR and _EFIREC macro variables is typical.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Sep 2018 08:57:30 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-09-27T08:57:30Z</dc:date>
    <item>
      <title>strange way of doing export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499399#M132888</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I found this code in my work.&lt;/P&gt;
&lt;P&gt;As I see this code is doing export of the table .&lt;/P&gt;
&lt;P&gt;I want to ask you what is this way of creating export?&lt;/P&gt;
&lt;P&gt;It is my first time that I see it.&lt;/P&gt;
&lt;P&gt;Can we also control style of exported table here?&lt;/P&gt;
&lt;P&gt;what is the name of this method of exporting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set  output_tbl&amp;amp;mon.    end=EFIEOD;
%let _EFIERR_ = 0; 
%let _EFIREC_ = 0;  
file "Path" delimiter=',' DSD
DROPOVER lrecl=32767;
format score best12. ;
format customers&amp;amp;dec. best12. ;
format obligation&amp;amp;dec. best12. ;
format allowance&amp;amp;dec. 15.2 ;
format customers&amp;amp;mon. best12. ;
format obligation&amp;amp;mon. best12. ;
format allowance&amp;amp;mon. 15.2 ;
if _n_ = 1 then        
do;
put
'Score'
','
'Customers DEC'
','
'Obligation DEC'
','
'allowance DEC '
','
'Customers Current month'
','
'Obligation Current month'
','
'allowance  Current month'
;
end;
do;
EFIOUT + 1;
put score @;
put customers&amp;amp;dec. @;
put obligation&amp;amp;dec. @;
put allowance&amp;amp;dec. @;
put customers&amp;amp;mon. @;
put obligation&amp;amp;mon. @;
put allowance&amp;amp;mon. ;
;
end;
if _ERROR_ then call symputx('_EFIERR_',1);  
if EFIEOD then call symputx('_EFIREC_',EFIOUT);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Sep 2018 08:26:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499399#M132888</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-09-27T08:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: strange way of doing export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499401#M132889</link>
      <description>&lt;P&gt;Its just writing data out to a plain text file.&amp;nbsp; &amp;nbsp;This:&lt;/P&gt;
&lt;PRE&gt;file "Path" delimiter=',' DSD
DROPOVER lrecl=32767;&lt;/PRE&gt;
&lt;P&gt;Is showing the filename, and that the file is to be comma delimited.&lt;/P&gt;
&lt;P&gt;This produces the header row:&lt;/P&gt;
&lt;PRE&gt;put
'Score'
','
...&lt;/PRE&gt;
&lt;P&gt;This writes the data:&lt;/P&gt;
&lt;PRE&gt;put score @;
put customers&amp;amp;dec. @;
put obligation&amp;amp;dec. @;
...&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp;@ means hold the line pointer, i.e. so all items get written to the same row.&lt;/P&gt;
&lt;P&gt;Its an oldschool way of writing data to files, preceding proc report, tagsets etc. which are layers on top of the file writing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We used to write patient profiles outputs using this technique - though a fair bit more complicated, using algorithms to position text and what not.&amp;nbsp; Now its all BI tools and fancy pants R outputs.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 08:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499401#M132889</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-27T08:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: strange way of doing export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499404#M132890</link>
      <description>&lt;P&gt;Looks a lot like code taken initially from the log of a proc export run. Use of _EFIERR and _EFIREC macro variables is typical.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 08:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499404#M132890</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-27T08:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: strange way of doing export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499416#M132896</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;So ,do you prefer to use proc export (which is much shorter code)?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 09:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499416#M132896</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-09-27T09:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: strange way of doing export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499419#M132898</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;So ,do you prefer to use proc export (which is much shorter code)?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is the important difference between proc import and proc export: avoid using proc import if you can, but use proc export as long as you don't need some really fancy text-files.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 09:55:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499419#M132898</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-09-27T09:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: strange way of doing export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499427#M132903</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;So ,do you prefer to use proc export (which is much shorter code)?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unless you need some fancy look for the external file, proc export is the way to go. Since the source is well controlled (a SAS dataset), there are no ambiguities for the structure of the output. As long as the dataset keeps its structure, the external file will look the same.&lt;/P&gt;
&lt;P&gt;If you need only some columns, just use a keep= dataset option.&lt;/P&gt;
&lt;P&gt;Proc import, OTOH, works from an undefined source and needs to make guesses about the underlying structure, so the result will not be consistent; that's why an explicitly written data step is preferred.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 10:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499427#M132903</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-27T10:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: strange way of doing export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499534#M132948</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;So ,do you prefer to use proc export (which is much shorter code)?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's true in this case, but not always. From a 'short' perspective you can write a data step to export that is shorter if you wanted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They're both tools that you can use. One is simpler (PROC) and the other&amp;nbsp;provides more control - if you wanted to do a calculation in the same step, or customize the output with different lines for a single observation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 14:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499534#M132948</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-27T14:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: strange way of doing export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499544#M132953</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;So ,do you prefer to use proc export (which is much shorter code)?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It depends on what is needed. Proc export without a little adjustment to the code always exports all variables an you don't have any control over the order of variables in the output and the values are exported using the variables default formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to change the order or the formatted appearance of variables then proc export may not be what you want. Then you could do something similar as shown based on Proc Export code but modified to only have the variables in specific order.&lt;/P&gt;
&lt;P&gt;These days I would likely use ODS CSV and Proc print instead of going through the data step if there were no additional variables needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And NOT at all strange. I wrote a lot of that sort of data step code early in my SAS career as I was working with a group of modelers that needed input files in very specific layouts so that the FORTRAN code they were writing could read the files. If you ever work with FORTRAN you will find that the input from external files is not anywhere near as flexible as SAS and writing to their input standards for the input files was much more robust then changing the code to read the input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 15:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-way-of-doing-export/m-p/499544#M132953</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-27T15:05:49Z</dc:date>
    </item>
  </channel>
</rss>

