<?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: Replacing values of a column with its minimum value in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609091#M17812</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/302099"&gt;@npr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get the minimum of X and Y externally using ProcSQL. Then you can replace the original X and Y by min X and min Y in a Data Step. Assumed your input data is named as HAVE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql noprint;
   select min(X), min(Y) into :minX, :minY
   from have
   ;
quit;

%put &amp;amp;minX;
%put &amp;amp;minY;

data want;
   set have;
   X = &amp;amp;minX;
   Y = &amp;amp;minY;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another way is to use a single Data step. In the first part you can get the minimum of&amp;nbsp; X and minimum of Y and in the second part the original X and Y are replaced by the corresponding minimum values of X and Y.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
   if _n_ = 1 then do until(eof);
      set have end = eof;
      if not missing(X) then minX = min(minX, X);
      minY = min(minY, Y);
   end;
   retain minX minY;
   set have;
   X = minX;
   Y = minY;
drop minX minY;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 03 Dec 2019 15:41:18 GMT</pubDate>
    <dc:creator>KachiM</dc:creator>
    <dc:date>2019-12-03T15:41:18Z</dc:date>
    <item>
      <title>Replacing values of a column with its minimum value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609062#M17805</link>
      <description>&lt;DIV class="votecell post-layout--left"&gt;&lt;DIV class="js-voting-container grid fd-column ai-stretch gs4 fc-black-200"&gt;&lt;DIV class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="postcell post-layout--right"&gt;&lt;DIV class="post-text"&gt;&lt;P&gt;i am very new to sas and I have the following work table&lt;/P&gt;&lt;P&gt;&lt;A href="https://i.stack.imgur.com/lss6T.png" target="_blank" rel="nofollow noopener noreferrer"&gt;&lt;IMG src="https://i.stack.imgur.com/lss6T.png" border="0" alt="enter image description here" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I want to create a new table in which column Date and Z remain the same, but all values in column X are replaced with the minimum value in column X and all values in column Y are replaced with the minimum value in column y.&lt;/P&gt;&lt;P&gt;Sample output is as follows&lt;/P&gt;&lt;P&gt;&lt;A href="https://i.stack.imgur.com/gKx2i.png" target="_blank" rel="nofollow noopener noreferrer"&gt;&lt;IMG src="https://i.stack.imgur.com/gKx2i.png" border="0" alt="enter image description here" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 Dec 2019 14:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609062#M17805</guid>
      <dc:creator>npr</dc:creator>
      <dc:date>2019-12-03T14:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values of a column with its minimum value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609064#M17806</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/302099"&gt;@npr&lt;/a&gt;&amp;nbsp; &amp;nbsp;Where is the sample input and expected output?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2019 14:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609064#M17806</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-03T14:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values of a column with its minimum value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609091#M17812</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/302099"&gt;@npr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get the minimum of X and Y externally using ProcSQL. Then you can replace the original X and Y by min X and min Y in a Data Step. Assumed your input data is named as HAVE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql noprint;
   select min(X), min(Y) into :minX, :minY
   from have
   ;
quit;

%put &amp;amp;minX;
%put &amp;amp;minY;

data want;
   set have;
   X = &amp;amp;minX;
   Y = &amp;amp;minY;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another way is to use a single Data step. In the first part you can get the minimum of&amp;nbsp; X and minimum of Y and in the second part the original X and Y are replaced by the corresponding minimum values of X and Y.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
   if _n_ = 1 then do until(eof);
      set have end = eof;
      if not missing(X) then minX = min(minX, X);
      minY = min(minY, Y);
   end;
   retain minX minY;
   set have;
   X = minX;
   Y = minY;
drop minX minY;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Dec 2019 15:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609091#M17812</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-12-03T15:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values of a column with its minimum value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609093#M17813</link>
      <description>&lt;P&gt;Don't replace the data (as you will lose information). Instead create a new dataset with the values you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
  create table want as
    select date,x, min(y) as y, min(z) as z
    from have 
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Dec 2019 15:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609093#M17813</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-03T15:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values of a column with its minimum value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609292#M17862</link>
      <description>Thanks Tom . Just another add on question , if i only want values from 2002Q1 to be replaced with the minimum value , how do i go about it ?</description>
      <pubDate>Wed, 04 Dec 2019 08:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609292#M17862</guid>
      <dc:creator>npr</dc:creator>
      <dc:date>2019-12-04T08:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values of a column with its minimum value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609298#M17864</link>
      <description>proc sql;&lt;BR /&gt;create table work.macro_eco_new as&lt;BR /&gt;select date, x, y, z&lt;BR /&gt;If date &amp;gt;= "2002Q1",then select min(x) as x, min(y) as y&lt;BR /&gt;from work.macro_eco&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;This is what i tried</description>
      <pubDate>Wed, 04 Dec 2019 08:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replacing-values-of-a-column-with-its-minimum-value/m-p/609298#M17864</guid>
      <dc:creator>npr</dc:creator>
      <dc:date>2019-12-04T08:23:52Z</dc:date>
    </item>
  </channel>
</rss>

