<?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: Change values with same value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-values-with-same-value/m-p/754123#M237758</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To understand what your code is doing, I recommend you look at the&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p1kfea7go1hi5qn1beilekqz6pf2.htm" target="_self"&gt;Automatic Variables documentation.&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;_N_ is initially set to 1. Each time the DATA step loops past the DATA statement, the variable _N_ increments by 1. The value of _N_ represents the number of times the DATA step has iterated.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As your IF statement is comparing _n_ with the variable age (sashelp.class) then you probably only set a single observation to 20. Observation #11 is Joyce and her age is 11, as _n_ would be 11 and age is 11 then you set age to 20 for that single observation.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jul 2021 16:02:06 GMT</pubDate>
    <dc:creator>AMSAS</dc:creator>
    <dc:date>2021-07-14T16:02:06Z</dc:date>
    <item>
      <title>Change values with same value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-values-with-same-value/m-p/754113#M237753</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dss;
set sashelp.class;
run;



data ddd;
set dss;
if age = _n_  then age= 20 ;
proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want replace all age values with 20&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 15:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-values-with-same-value/m-p/754113#M237753</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-07-14T15:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Change values with same value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-values-with-same-value/m-p/754120#M237757</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dss;
    set sashelp.class;
    age=20;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jul 2021 15:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-values-with-same-value/m-p/754120#M237757</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-14T15:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Change values with same value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-values-with-same-value/m-p/754123#M237758</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To understand what your code is doing, I recommend you look at the&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p1kfea7go1hi5qn1beilekqz6pf2.htm" target="_self"&gt;Automatic Variables documentation.&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;_N_ is initially set to 1. Each time the DATA step loops past the DATA statement, the variable _N_ increments by 1. The value of _N_ represents the number of times the DATA step has iterated.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As your IF statement is comparing _n_ with the variable age (sashelp.class) then you probably only set a single observation to 20. Observation #11 is Joyce and her age is 11, as _n_ would be 11 and age is 11 then you set age to 20 for that single observation.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-values-with-same-value/m-p/754123#M237758</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-07-14T16:02:06Z</dc:date>
    </item>
  </channel>
</rss>

