<?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: writing observations to an external file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506960#M135964</link>
    <description>&lt;P&gt;Next time post your code within the man-icon window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replace the '????...?' with:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month $3.&amp;nbsp; amount 7.2 /&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but you still need to recognize a start of a new name, so your code need be -&lt;/P&gt;
&lt;P&gt;Suppose you read your input into sas dataset named 'have':&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 .... /* your code */
         if not missing(name) then 
            put 'Hi ' name // 'Your do.....: '    /* your text */
                / month $3.  amount dollar7.2 ;
        else   put / mont $3.  amount dollar7.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Oct 2018 18:18:01 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2018-10-23T18:18:01Z</dc:date>
    <item>
      <title>writing observations to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506952#M135956</link>
      <description>&lt;P&gt;guys ...&amp;nbsp;&lt;/P&gt;&lt;P&gt;stuck on a small basic problem ..&amp;nbsp;&lt;/P&gt;&lt;P&gt;need to write to a file but using values from subsequent observations ..&amp;nbsp;&lt;/P&gt;&lt;P&gt;the attached image explains the issue .. please help with code to replace "????????" part ..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 17:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506952#M135956</guid>
      <dc:creator>jfaruqui</dc:creator>
      <dc:date>2018-10-23T17:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: writing observations to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506953#M135957</link>
      <description>&lt;P&gt;So the window is what you want the txt file to look like, correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you post the code here so we can provide a code answer?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 17:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506953#M135957</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-23T17:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: writing observations to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506954#M135958</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;sure ...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;data _null_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;infile datalines;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;input ID Name$ 6-13 Month$ Amount;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;file '/folders/myfolders/Donations.txt' print;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;PUT&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;'Hi' name&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;//'Your donation(s) are as follows:'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// ???????;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;put _page_;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;cards;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;1001 Jenny&amp;nbsp; &amp;nbsp;JAN 300&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;JUL 550&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DEC 275&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;1002 George&amp;nbsp; AUG 100&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;1003 Frank&amp;nbsp; &amp;nbsp;FEB 375&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;1003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NOV 460&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 18:02:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506954#M135958</guid>
      <dc:creator>jfaruqui</dc:creator>
      <dc:date>2018-10-23T18:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: writing observations to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506955#M135959</link>
      <description>&lt;P&gt;Is this what your &lt;STRONG&gt;actual&amp;nbsp;&lt;/STRONG&gt;data looks like? This is probably not the data you want to work with?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input ID Name$ Month$ Amount;
cards;
1001 Jenny JAN 300
1001 JUL 550
1001 DEC 275
1002 George AUG 100
1003 Frank FEB 375
1003 NOV 460
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I'm guessing your data looks more like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input ID Name$ Month$ Amount;
infile datalines dlm=',' dsd;
cards;
1001,Jenny,JAN,300
1001,,JUL,550
1001,,DEC,275
1002,George,AUG,100
1003,Frank,FEB,375
1003,,NOV,460
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Oct 2018 18:04:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506955#M135959</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-23T18:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: writing observations to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506956#M135960</link>
      <description>&lt;P&gt;&lt;FONT face="andale mono,times"&gt;looks more like this ... copy/paste is screwing up the spacing&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;i wouldn't mind making a dataset with this data and then using the dataset to generate the txt files either ... so we can use the BY statement (in case first. and last. needs to be used)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;----x----1----x----2----x----3&lt;BR /&gt;1001 Jenny&amp;nbsp; &amp;nbsp;JAN 300&lt;BR /&gt;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;JUL 550&lt;BR /&gt;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DEC 275&lt;BR /&gt;1002 George&amp;nbsp; AUG 100&lt;BR /&gt;1003 Frank&amp;nbsp; &amp;nbsp;FEB 375&lt;BR /&gt;1003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NOV 460&lt;BR /&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 18:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506956#M135960</guid>
      <dc:creator>jfaruqui</dc:creator>
      <dc:date>2018-10-23T18:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: writing observations to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506957#M135961</link>
      <description>that works too bro ... its not the data entry that is tripping me up .. its what to write in the PUT statement that allows me to create reports for the 3 users with their donation months and amounts ..</description>
      <pubDate>Tue, 23 Oct 2018 18:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506957#M135961</guid>
      <dc:creator>jfaruqui</dc:creator>
      <dc:date>2018-10-23T18:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: writing observations to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506959#M135963</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input ID Name$ Month$ Amount;
infile datalines dlm=',' dsd;
cards;
1001,Jenny,JAN,300
1001,,JUL,550
1001,,DEC,275
1002,George,AUG,100
1003,Frank,FEB,375
1003,,NOV,460
;

data _null_;
   set test;
   by ID;
   file 'Yourpath\Donations.txt';
   if first.ID then put "Hi " Name
   / "Your donation(s) are as follows"
   / Month Amount dollar10.2;
   if not first.ID then put Month Amount dollar10.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Oct 2018 18:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506959#M135963</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-23T18:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: writing observations to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506960#M135964</link>
      <description>&lt;P&gt;Next time post your code within the man-icon window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replace the '????...?' with:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month $3.&amp;nbsp; amount 7.2 /&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but you still need to recognize a start of a new name, so your code need be -&lt;/P&gt;
&lt;P&gt;Suppose you read your input into sas dataset named 'have':&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 .... /* your code */
         if not missing(name) then 
            put 'Hi ' name // 'Your do.....: '    /* your text */
                / month $3.  amount dollar7.2 ;
        else   put / mont $3.  amount dollar7.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 18:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506960#M135964</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-10-23T18:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: writing observations to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506977#M135967</link>
      <description>&lt;P&gt;thanks all !!!&lt;/P&gt;&lt;P&gt;I love this site and these boards !!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 18:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-observations-to-an-external-file/m-p/506977#M135967</guid>
      <dc:creator>jfaruqui</dc:creator>
      <dc:date>2018-10-23T18:27:46Z</dc:date>
    </item>
  </channel>
</rss>

