<?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: How to create a new variable using max value of a continuous variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-using-max-value-of-a-continuous/m-p/834040#M329740</link>
    <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
    var fx;
    output out=max_value max=max_fx;
run;
data want;
    if _n_=1 then set max_value;
    set have;
    if fx=max_fx then max_fx_flag+1;
    if max_fx_flag&amp;gt;0 then output;
    drop _type_ _freq_ max_fx_flag max_fx;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 18 Sep 2022 22:35:38 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-09-18T22:35:38Z</dc:date>
    <item>
      <title>How to create a new variable using max value of a continuous variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-using-max-value-of-a-continuous/m-p/834039#M329739</link>
      <description>&lt;P&gt;Hi Sas experts,&lt;/P&gt;&lt;P&gt;I have a data set (n= 5000+ observations) with a continuous variable Fx, with values ranging from positive to negative. I want to identify the max value of Fx and select only those observations starting with the max value and all the observations below them. For example if the max value for Fx is on row/ observation 2295, then I want all observations from 2295 to 5000 as a separate data set. If the max value for Fx is on row 1350, then I would like to select row 1350 to row 5000 as a separate data set. Is this possible? I dont want to arrange them in ascending or descending order. From the existing data set, as is, I would like to identify the highest value for Fx column and pick up all observations with highest value for Fx and all rows below the highest value as a separate data set. I have about 270 such data sets. I would really appreciate any help with this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have:&lt;/P&gt;&lt;P&gt;Fx&lt;/P&gt;&lt;P&gt;0.25&lt;/P&gt;&lt;P&gt;0.26&lt;/P&gt;&lt;P&gt;0.27&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0.33&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;0.29&lt;/P&gt;&lt;P&gt;0.24&lt;/P&gt;&lt;P&gt;0.19&lt;/P&gt;&lt;P&gt;-0.11&lt;/P&gt;&lt;P&gt;-.28&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want:&lt;/P&gt;&lt;P&gt;Fx&lt;/P&gt;&lt;P&gt;0.33&lt;/P&gt;&lt;P&gt;0.29&lt;/P&gt;&lt;P&gt;0.24&lt;/P&gt;&lt;P&gt;0.19&lt;/P&gt;&lt;P&gt;-0.11&lt;/P&gt;&lt;P&gt;-.28&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance,&lt;/P&gt;&lt;P&gt;SM&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2022 22:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-using-max-value-of-a-continuous/m-p/834039#M329739</guid>
      <dc:creator>sms1891</dc:creator>
      <dc:date>2022-09-18T22:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable using max value of a continuous variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-using-max-value-of-a-continuous/m-p/834040#M329740</link>
      <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
    var fx;
    output out=max_value max=max_fx;
run;
data want;
    if _n_=1 then set max_value;
    set have;
    if fx=max_fx then max_fx_flag+1;
    if max_fx_flag&amp;gt;0 then output;
    drop _type_ _freq_ max_fx_flag max_fx;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Sep 2022 22:35:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-new-variable-using-max-value-of-a-continuous/m-p/834040#M329740</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-18T22:35:38Z</dc:date>
    </item>
  </channel>
</rss>

