<?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: Adding Variables to ASCII data file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232263#M42322</link>
    <description>&lt;P&gt;Thanks for the tips and advice Mike &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;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Oct 2015 16:32:55 GMT</pubDate>
    <dc:creator>pawaterman</dc:creator>
    <dc:date>2015-10-29T16:32:55Z</dc:date>
    <item>
      <title>Adding Variables to ASCII data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232182#M42304</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I put variable names on top of the ASCII data file I am creating?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any insight would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Patrick&lt;BR /&gt;&lt;BR /&gt;data ASCII;&lt;BR /&gt;set final.merged_data;&lt;BR /&gt;NEW_BP=LOG(BP/LAG(BP));&lt;BR /&gt;NEW_CD=LOG(CD/LAG(CD));&lt;BR /&gt;NEW_DM=LOG(DM/LAG(DM));&lt;BR /&gt;NEW_JY=LOG(JY/LAG(JY));&lt;BR /&gt;NEW_SF=LOG(SF/LAG(SF));&lt;BR /&gt;file '/folders/myfolders/sasuser.v94/ascii.txt';&lt;BR /&gt;drop DAY;&lt;BR /&gt;drop BP;&lt;BR /&gt;drop CD;&lt;BR /&gt;drop DM;&lt;BR /&gt;drop JY;&lt;BR /&gt;drop SF;&lt;BR /&gt;format DATE MMDDYY10. NEW_BP NEW_CD NEW_DM NEW_JY NEW_SF;&lt;BR /&gt;put DATE MMDDYY10. NEW_BP NEW_CD NEW_DM NEW_JY NEW_SF;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 12:11:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232182#M42304</guid>
      <dc:creator>pawaterman</dc:creator>
      <dc:date>2015-10-29T12:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to ASCII data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232187#M42305</link>
      <description>&lt;P&gt;Hi.&amp;nbsp; An easy way is to just print the data set rather than using a PUT statement in a data setp.&amp;nbsp; For example, use&amp;nbsp;ODS CSV and chamhe the delimiter to a space&amp;nbsp;(same thing you are doing in your PUT statement, you could always add the date format in PROC PRINT) ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ods csv file='z:\class.txt' options(delimiter=' ');&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;proc print data=sashelp.class noobs;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ods csv close;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;portion of CLASS.TXT ...&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;"Name" "Sex" "Age" "Height" "Weight"&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;"Alfred" "M" 14 69.0 112.5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;"Alice" "F" 13 56.5 84.0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;"Barbara" "F" 13 65.3 98.0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;"Carol" "F" 14 62.8 102.5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 12:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232187#M42305</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2015-10-29T12:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to ASCII data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232195#M42306</link>
      <description>&lt;P&gt;Just as an alternative:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select NAME
  into   :HEAD separated by ","
  from   DICTIONARY.COLUMNS
  where  LIBNAME="SASHELP"
    and  MEMNAME="CARS";
quit;
data _null_;
  set sashelp.cars;
  file "c:\xyz.csv" dlm=",";
  if _n_=1 then put "&amp;amp;HEAD.";
  else put make model type;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note, the datastep method does allow you to do processing, and other nice things whilst exporting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 12:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232195#M42306</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-10-29T12:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to ASCII data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232217#M42308</link>
      <description>&lt;P&gt;Old school:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ASCII;
set final.merged_data;
NEW_BP=LOG(BP/LAG(BP));
NEW_CD=LOG(CD/LAG(CD));
NEW_DM=LOG(DM/LAG(DM));
NEW_JY=LOG(JY/LAG(JY));
NEW_SF=LOG(SF/LAG(SF));
file '/folders/myfolders/sasuser.v94/ascii.txt';
drop DAY;
drop BP;
drop CD;
drop DM;
drop JY;
drop SF;
format DATE MMDDYY10. NEW_BP NEW_CD NEW_DM NEW_JY NEW_SF;
If _n_ = 1 then put "Date" +5 "New_BP" +5 "New_CD" +5 "New_JY" +5 "New_SF";
put DATE MMDDYY10. NEW_BP NEW_CD NEW_DM NEW_JY NEW_SF;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Adjust the column movements, the +5, to align. You might want to consider using column assignments in the put to align data in columns&amp;nbsp;as well, in which case use the same column assignments&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 14:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232217#M42308</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-29T14:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to ASCII data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232250#M42315</link>
      <description>&lt;P&gt;Hi. &amp;nbsp;You got a bunch of answers. &amp;nbsp;Great. &amp;nbsp;How about some 'NEW USER' stuff ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why all the DROP statements? &amp;nbsp;How about ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;drop DAY&amp;nbsp;BP&amp;nbsp;CD&amp;nbsp;DM&amp;nbsp;JY&amp;nbsp;SF;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Also, not sure what this does ...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;SPAN&gt;format DATE MMDDYY10. NEW_BP NEW_CD NEW_DM NEW_JY NEW_SF;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;All it would do is remove the formats from all the NEW_ variables since there is no format used at the end of the format for those variables. But you created those variables within the data step and they have no formats associated with them.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Last, you have DATE in a FORMAT statement and you also have a format for DATE in the PUT statement. &amp;nbsp;One of those is enough. If a variable has been assigned a format (in this case MMDDYY10.), it will be formatted when you use a PUT statement (no need to repeat the format).&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 16:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232250#M42315</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2015-10-29T16:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to ASCII data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232263#M42322</link>
      <description>&lt;P&gt;Thanks for the tips and advice Mike &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;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 16:32:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232263#M42322</guid>
      <dc:creator>pawaterman</dc:creator>
      <dc:date>2015-10-29T16:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Variables to ASCII data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232264#M42323</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 16:35:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Variables-to-ASCII-data-file/m-p/232264#M42323</guid>
      <dc:creator>pawaterman</dc:creator>
      <dc:date>2015-10-29T16:35:49Z</dc:date>
    </item>
  </channel>
</rss>

