<?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: Do i=1 to variable name? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509474#M1789</link>
    <description>&lt;P&gt;Show us the SASLOG. Click on the {i} icon and paste your SASLOG into that window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I execute your code, I do not get an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Nov 2018 12:15:45 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-11-01T12:15:45Z</dc:date>
    <item>
      <title>Do i=1 to variable name?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509471#M1786</link>
      <description>&lt;P&gt;Hi can anyone please help me out with this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile datalines dlm=',' dsd missover;
input id:$ no_visit unit_purchased@;
do i=1 to no_visit;
input unit_purchased@;
if unit_purchased=. then unit_purchased =0;
output;	
end;
drop i no_visit;
datalines; 
C005,3,15,,39
D2356,4,11,,,5
A323,3,10,15,20
F123,1,
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I somehow got an error and SAS failed to output (15,11,10&amp;amp;1).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 12:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509471#M1786</guid>
      <dc:creator>ywhui9</dc:creator>
      <dc:date>2018-11-01T12:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Do i=1 to variable name?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509473#M1788</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/243889"&gt;@ywhui9&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this corrected DATA step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines dlm=',' dsd missover;
input id $ no_visit @;
do i=1 to no_visit;
  input unit_purchased @;
  if unit_purchased=. then unit_purchased=0;
  output;	
end;
drop i no_visit;
datalines; 
C005,3,15,,39
D2356,4,11,,,5
A323,3,10,15,20
F123,1,
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Edit: In your code you read the first value of UNIT_PURCHASED with the first INPUT statement, but before the OUTPUT statement you read the second value with the second INPUT statement, so the first value was overwritten.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 12:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509473#M1788</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-01T12:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Do i=1 to variable name?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509474#M1789</link>
      <description>&lt;P&gt;Show us the SASLOG. Click on the {i} icon and paste your SASLOG into that window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I execute your code, I do not get an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 12:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509474#M1789</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-01T12:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Do i=1 to variable name?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509479#M1791</link>
      <description>&lt;P&gt;Thanks all !!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 12:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509479#M1791</guid>
      <dc:creator>ywhui9</dc:creator>
      <dc:date>2018-11-01T12:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Do i=1 to variable name?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509480#M1792</link>
      <description>&lt;P&gt;Hi, The reason you are not getting first unit_purchased, in the output is that&amp;nbsp;you override the value before the output statement with the 2nd input statement.&lt;BR /&gt;In the 1st input statement, the code reads in id=C005 no_visit=3 unit_purchased=15. Then you drop into the do loop and the 2nd input statement reads in unit_purchased=. (missing). This happens each time you go to a new observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add another output statement after the 1st input statement, should solve the issue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 12:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509480#M1792</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2018-11-01T12:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Do i=1 to variable name?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509484#M1793</link>
      <description>&lt;P&gt;Thank you for the explanation! Have a nice day &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 12:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509484#M1793</guid>
      <dc:creator>ywhui9</dc:creator>
      <dc:date>2018-11-01T12:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Do i=1 to variable name?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509488#M1794</link>
      <description>&lt;P&gt;Thank you for the explanation! It helps a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 12:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Do-i-1-to-variable-name/m-p/509488#M1794</guid>
      <dc:creator>ywhui9</dc:creator>
      <dc:date>2018-11-01T12:33:10Z</dc:date>
    </item>
  </channel>
</rss>

