<?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: export in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120418#M33201</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not familiar with proc sql.&amp;nbsp; &lt;/P&gt;&lt;P&gt;can I add a line or two to have the variable name in this coed?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;set Coded1;&lt;/P&gt;&lt;P&gt;file "C:\data\d1.csv" dsd dlm=',';&lt;/P&gt;&lt;P&gt;put CE $ 1-20 item1-item116;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Nov 2012 15:08:02 GMT</pubDate>
    <dc:creator>R_A_G_</dc:creator>
    <dc:date>2012-11-08T15:08:02Z</dc:date>
    <item>
      <title>export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120414#M33197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;How can I export a data set in csv format and keep the variable name in the first row.&lt;/P&gt;&lt;P&gt;This is mine but the names are not exported.&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;set CED;&lt;/P&gt;&lt;P&gt;file "C:\DATA\d1.csv" dsd dlm=',';&lt;/P&gt;&lt;P&gt;put CE $ 1-20 item1-item116;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried another way with PROC EXPORT but have issues with it as well, it's keep asking for TABLE:&lt;/P&gt;&lt;P&gt;PROC EXPORT data=CED;&lt;/P&gt;&lt;P&gt;file="C:\\DATA\d3.csv" ;&lt;/P&gt;&lt;P&gt;dbms=dlm;&lt;/P&gt;&lt;P&gt;DELIMITER==',';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 23:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120414#M33197</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2012-11-07T23:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120415#M33198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;PROC EXPORT data=CED&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;outfile="C:\DATA\d3.csv" &lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;dbms=csv replace;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;putnames=yes;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 23:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120415#M33198</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-11-07T23:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120416#M33199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks that was correct only one problem. I need to truncate the first variable to less than 20 spaces.&lt;/P&gt;&lt;P&gt;How can I do that in the above code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CE $ 1-20&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 01:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120416#M33199</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2012-11-08T01:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120417#M33200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't do it using Proc Export, which does not has the control over individual variable. You may need to go back to data step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename out 'C:\DATA\';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql NOPRINT;&lt;/P&gt;&lt;P&gt; select name into :name separated by ' ' from DICTIONARY.COLUMNS WHERE LIBNAME='WORK' AND MEMNAME='CED';/*HAS TO BE CAPS, HERE AND BELOW*/&lt;/P&gt;&lt;P&gt; SELECT NAME INTO :QNAME&amp;nbsp; separated by ',' from DICTIONARY.COLUMNS WHERE LIBNAME='WORK' AND MEMNAME='CED';;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_; &lt;/P&gt;&lt;P&gt;length CE $20;&lt;/P&gt;&lt;P&gt;set CED;&lt;/P&gt;&lt;P&gt;file out(D3.csv) dsd; &lt;/P&gt;&lt;P&gt;IF _n_=1 then put "&amp;amp;QNAME";&lt;/P&gt;&lt;P&gt;put &amp;amp;name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 04:12:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120417#M33200</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-08T04:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120418#M33201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not familiar with proc sql.&amp;nbsp; &lt;/P&gt;&lt;P&gt;can I add a line or two to have the variable name in this coed?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;set Coded1;&lt;/P&gt;&lt;P&gt;file "C:\data\d1.csv" dsd dlm=',';&lt;/P&gt;&lt;P&gt;put CE $ 1-20 item1-item116;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:08:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120418#M33201</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2012-11-08T15:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120419#M33202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SQL part of code is just to save your effort of typing in all of your variable names, if you have too many. otherwise, you can simply ignore it.&lt;/P&gt;&lt;P&gt;However, the 'length' statement has to be put BEFORE 'set' statement, and I don't think you need dlm=',', as dsd already has it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;length CE $20;&lt;/P&gt;&lt;P&gt;set Coded1;&lt;/P&gt;&lt;P&gt;file "C:\data\d1.csv" dsd ;&lt;/P&gt;&lt;P&gt;if _n_=1 then put "CE, item1, item2, ......item116"; /*if you don't mind typing*/&lt;/P&gt;&lt;P&gt;put CE&amp;nbsp; item1-item116;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:16:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120419#M33202</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-08T15:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120420#M33203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Haikuo,&lt;/P&gt;&lt;P&gt;Do you think it would work if shorten the variable before exporting to csv file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data coded1;&lt;/P&gt;&lt;P&gt;length ce $20;&lt;/P&gt;&lt;P&gt;set coded1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120420#M33203</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-11-08T15:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120421#M33204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LinLin,&lt;/P&gt;&lt;P&gt;It surely will work, however, one more pass will be involved as well, if efficiency is part of your equation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120421#M33204</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-08T15:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120422#M33205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi R.A.G.&lt;/P&gt;&lt;P&gt;If you don't care about efficiency then try the code below&lt;SPAN style="color: #ff0000;"&gt;(replace the colored parts&lt;/SPAN&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &lt;SPAN style="color: #ff0000;"&gt;temp&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;length&lt;SPAN style="color: #ff0000;"&gt; ce&lt;/SPAN&gt; $20;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set &lt;SPAN style="color: #ff0000;"&gt;your_dataset&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;PROC EXPORT data=&lt;SPAN style="color: #ff0000;"&gt;temp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;outfile="C:\DATA\d3.csv"&lt;/P&gt;&lt;P&gt;dbms=csv replace;&lt;/P&gt;&lt;P&gt;putnames=yes;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120422#M33205</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-11-08T15:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120423#M33206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LinLin,&lt;/P&gt;&lt;P&gt;I think you have just provided a solution that OP will most likely be comfortable with &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;. You are always the nicer one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/export/m-p/120423#M33206</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-08T15:48:29Z</dc:date>
    </item>
  </channel>
</rss>

