<?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: Creating a new variable and changing some values in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537955#M33131</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input n;
cards;
100
90
85
80
90
70
90 
80
75 
60
50
;
data want;
 set have;
 retain min 99999;
 min=min(min,n);
 if min&amp;lt;n then call missing(n);
 drop min;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 23 Feb 2019 11:41:15 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-02-23T11:41:15Z</dc:date>
    <item>
      <title>Creating a new variable and changing some values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537717#M33111</link>
      <description>&lt;P&gt;Hi, everybody!&lt;/P&gt;&lt;P&gt;I have a variable which must be descending, but I have some values that brokes this rule. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;90&lt;/P&gt;&lt;P&gt;85&lt;/P&gt;&lt;P&gt;80&lt;/P&gt;&lt;P&gt;90 &amp;lt;---&lt;/P&gt;&lt;P&gt;70&lt;/P&gt;&lt;P&gt;90&amp;nbsp;&amp;lt;---&lt;/P&gt;&lt;P&gt;80&amp;nbsp;&amp;lt;---&lt;/P&gt;&lt;P&gt;75&amp;nbsp;&amp;lt;---&lt;/P&gt;&lt;P&gt;60&lt;/P&gt;&lt;P&gt;50&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For these guys, I want substitute in a new variable for missing. This way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have&amp;nbsp; &amp;nbsp;Want&lt;/P&gt;&lt;P&gt;100&amp;nbsp; &amp;nbsp; &amp;nbsp; 100&lt;/P&gt;&lt;P&gt;90&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90&lt;/P&gt;&lt;P&gt;85&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;85&lt;/P&gt;&lt;P&gt;80&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;80&lt;/P&gt;&lt;P&gt;90 &amp;lt;---&amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;70&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;70&lt;/P&gt;&lt;P&gt;90&amp;nbsp;&amp;lt;---&amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;80&amp;nbsp;&amp;lt;---&amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;75&amp;nbsp;&amp;lt;---&amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;60&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;60&lt;/P&gt;&lt;P&gt;50&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I worked hard, but I couldn't. Anyone can help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 14:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537717#M33111</guid>
      <dc:creator>GDumont</dc:creator>
      <dc:date>2019-02-22T14:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable and changing some values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537719#M33112</link>
      <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data new;&lt;/P&gt;
&lt;P&gt;set old;&lt;/P&gt;
&lt;P&gt;if _n_=1 then last_valid = have;&lt;/P&gt;
&lt;P&gt;retain last_valid;&lt;/P&gt;
&lt;P&gt;if have &amp;lt;= last_valid then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;last_valid = have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;want = have;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's untested code, so you will have to see if it works for you.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 15:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537719#M33112</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-22T15:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable and changing some values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537720#M33113</link>
      <description>&lt;P&gt;Use the lag() and ifn() functions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want = ifn(have &amp;gt; lag(have) and _n_ ne 1,.,have);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: took care of the first data step iteration (thanks to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; for bringing that to my attention).&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 15:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537720#M33113</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-22T15:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable and changing some values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537722#M33114</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input n;
cards;
100
90
85
80
90
70
90 
80
75 
60
50
;

data temp;
set have;
retain want;
if _n_=1  then want=n;
else if n&amp;lt;want then want=n;
run;

data want;
set temp ;
by want notsorted;
if not first.want then call missing(want);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Feb 2019 15:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537722#M33114</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-22T15:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable and changing some values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537954#M33130</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input n;
cards;
100
90
85
80
90
70
90 
80
75 
60
50
;
data want;
 set have;
 retain min 99999;
 min=min(min,n);
 if min&amp;lt;n then call missing(n);
 drop min;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Feb 2019 11:37:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537954#M33130</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-02-23T11:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable and changing some values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537955#M33131</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input n;
cards;
100
90
85
80
90
70
90 
80
75 
60
50
;
data want;
 set have;
 retain min 99999;
 min=min(min,n);
 if min&amp;lt;n then call missing(n);
 drop min;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Feb 2019 11:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-a-new-variable-and-changing-some-values/m-p/537955#M33131</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-02-23T11:41:15Z</dc:date>
    </item>
  </channel>
</rss>

