<?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: Output to delimited format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292778#M60835</link>
    <description>&lt;P&gt;Beautiful! &amp;nbsp;Curious: where did 254 come from?&lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2016 16:32:14 GMT</pubDate>
    <dc:creator>GreggB</dc:creator>
    <dc:date>2016-08-19T16:32:14Z</dc:date>
    <item>
      <title>Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292767#M60829</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a SAS file that I cleaned up and now need to export it in the same format as the original dirty file. See the portion below. I starred out last and first name for privacy reasons. The original file does not have headers so I can't export those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Original file to mimic:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"37-01-017",10045,"Ravenel Elementary","********","********","F",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;SAS output I currently have:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="675"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="74"&gt;VAR1&lt;/TD&gt;
&lt;TD width="144"&gt;student_number&lt;/TD&gt;
&lt;TD width="163"&gt;VAR3&lt;/TD&gt;
&lt;TD width="114"&gt;first_name&lt;/TD&gt;
&lt;TD width="116"&gt;last_name&lt;/TD&gt;
&lt;TD width="64"&gt;VAR6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;37-01-017&lt;/TD&gt;
&lt;TD width="144"&gt;10045&lt;/TD&gt;
&lt;TD width="163"&gt;Ravenel Elementary&lt;/TD&gt;
&lt;TD width="114"&gt;******&lt;/TD&gt;
&lt;TD width="116"&gt;******&lt;/TD&gt;
&lt;TD width="64"&gt;F&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;37-01-027&lt;/TD&gt;
&lt;TD width="144"&gt;10103&lt;/TD&gt;
&lt;TD width="163"&gt;FairOak Elementary&lt;/TD&gt;
&lt;TD width="114"&gt;******&lt;/TD&gt;
&lt;TD width="116"&gt;******&lt;/TD&gt;
&lt;TD width="64"&gt;M&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;37-01-027&lt;/TD&gt;
&lt;TD width="144"&gt;10327&lt;/TD&gt;
&lt;TD width="163"&gt;FairOak Elementary&lt;/TD&gt;
&lt;TD width="114"&gt;******&lt;/TD&gt;
&lt;TD width="116"&gt;******&lt;/TD&gt;
&lt;TD width="64"&gt;F&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;37-01-022&lt;/TD&gt;
&lt;TD width="144"&gt;10332&lt;/TD&gt;
&lt;TD width="163"&gt;Walhalla Elementary&lt;/TD&gt;
&lt;TD width="114"&gt;******&lt;/TD&gt;
&lt;TD width="116"&gt;******&lt;/TD&gt;
&lt;TD width="64"&gt;M&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;37-01-028&lt;/TD&gt;
&lt;TD width="144"&gt;10511&lt;/TD&gt;
&lt;TD width="163"&gt;Orchard Park Elementary&lt;/TD&gt;
&lt;TD width="114"&gt;******&lt;/TD&gt;
&lt;TD width="116"&gt;******&lt;/TD&gt;
&lt;TD width="64"&gt;M&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 16:00:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292767#M60829</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2016-08-19T16:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292774#M60832</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would use the DATA Step to do this. Maybe there are some macros out there, that do exactly this.&lt;/P&gt;
&lt;P&gt;Currently the text is written to the SAS Log, so change the "log" to the "c:\yourname.csv" name you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DLM= option will add the commas between the values.&lt;/P&gt;
&lt;P&gt;The FORMAT statement assign the $QUOTE. format to all character variable, this cause all character variables to written out with quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have;
  file log  dlm=",";
  format _character_ $quote254.;
  put
    VAR1 
    student_number 
    VAR3 
    first_name 
    last_name 
    VAR6 
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 16:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292774#M60832</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2016-08-19T16:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292777#M60834</link>
      <description>&lt;P&gt;As mentioned you can do that easily with a data step.&amp;nbsp; I would use the DSD option which will quote values that contain the delimiter.&amp;nbsp; You use the SAS variable list _ALL_ in the PUT statement so you don't need to mention all the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   set sashelp.shoes(obs=50);
   file log dsd;
   put (_all_)(:);
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 16:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292777#M60834</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-08-19T16:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292778#M60835</link>
      <description>&lt;P&gt;Beautiful! &amp;nbsp;Curious: where did 254 come from?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 16:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292778#M60835</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2016-08-19T16:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292780#M60837</link>
      <description>This will be the max length for any char variable written to the file. You might need to adjust it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Bruno&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Aug 2016 16:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292780#M60837</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2016-08-19T16:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292781#M60838</link>
      <description>&lt;P&gt;I like the put (_all_) statement but it didn't enclose the vars in " ".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 16:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292781#M60838</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2016-08-19T16:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292790#M60839</link>
      <description>&lt;P&gt;If you want all values quoted use the ~ in place of :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put (_all_)(~);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 17:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292790#M60839</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-08-19T17:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292819#M60846</link>
      <description>&lt;P&gt;One more question: how can I amend the code to keep the var names and to change the delimiter to a space? &amp;nbsp;Maybe '09'x?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:26:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292819#M60846</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2016-08-19T19:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292822#M60848</link>
      <description>&lt;P&gt;By keep the var names I assume you mean create a name row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   set sashelp.shoes(obs=25);
   file log ls=256 dsd dlm='09'x;
   if _n_ eq 1 then link names;
   put (_all_)(~);
   return;
names:
   length _name_ $32;
   call missing(_name_);
   do while(1);
      call vnext(_name_);
      if _name_ eq: '_name_' then leave;
      put (_name_)(~) @;
      end;
   put; 
   run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292822#M60848</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-08-19T19:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292823#M60849</link>
      <description>&lt;P&gt;The space&amp;nbsp;delimiter is easy:&lt;/P&gt;
&lt;P&gt;dlm=' '&lt;/P&gt;
&lt;P&gt;unless you actually meant tab.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A manually build header row would look like:&lt;/P&gt;
&lt;P&gt;for comma delimited (placed &lt;STRONG&gt;before&lt;/STRONG&gt; the other put statement)&lt;/P&gt;
&lt;P&gt;if _n_ then put "var1, student_number,var3,first_name,Last_name,var6";&lt;/P&gt;
&lt;P&gt;or replace the comma with spaces for the space delimited. (or the '09'x for tab)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292823#M60849</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-19T19:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292829#M60851</link>
      <description>&lt;P&gt;The FILE statement option DLM= '09'X will deliver tab delimiters.&lt;/P&gt;&lt;P&gt;The FILE statement option DSD will protect all values that might (containing delimiter or " symbols) cause trouble. So the directive to format all character variables with quotes is unneccessary unless there is some other need to have all those quote marks. The DSD option will ensure a numeric value formatted as comma. &amp;nbsp;will be quoted when the DLM= &amp;nbsp;produces comma delimiters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292829#M60851</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2016-08-19T19:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Output to delimited format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292880#M60867</link>
      <description>&lt;PRE&gt;

ods _ALL_ CLOSE;
ods csv file='/folders/myfolders/want.csv' options(doc='help');
proc report data=sashelp.class nowd noheader;
run;
ods csv close;

&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Aug 2016 04:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-delimited-format/m-p/292880#M60867</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-20T04:19:44Z</dc:date>
    </item>
  </channel>
</rss>

