<?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: Base SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612121#M178541</link>
    <description>&lt;P&gt;In the code you provided earlier in message #3 in this thread, there are 8 input observations. My program produces 8 output observations, and is different than the output you show (and I think my code produces the correct answers).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, show your code.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2019 18:17:42 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-12-16T18:17:42Z</dc:date>
    <item>
      <title>Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612099#M178531</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've a dataset as mention below...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
input SUBJID Num;
datalines;
121 23
121 24
121 21
121 22
121 18
121 42
121 44
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My requirement is if i compare first two record then the smallest value would come into new variable. if i compare first 3 records then smallest value would come ... same way i have to take for others.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output needed as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUBJID Num NewVar&amp;nbsp;&lt;BR /&gt;121 23 &amp;nbsp;&lt;BR /&gt;121 24 23&lt;BR /&gt;121 21 21&lt;BR /&gt;121 22 21&lt;BR /&gt;121 18 18&lt;BR /&gt;121 42 18&lt;BR /&gt;121 44 18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance....&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 17:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612099#M178531</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2019-12-16T17:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612102#M178532</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
input SUBJID Num;
newvar=min(num,lag(num));
datalines;
121 23
121 24
121 21
121 22
121 18
121 42
121 44
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2019 17:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612102#M178532</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-16T17:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612104#M178533</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Thank you for quick response:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i've more then 6 records , in this case it's not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
input SUBJID Num;
newvar=min(num,lag(num));
datalines;
121 23
121 24
121 21
121 22
121 18
121 42
121 45
121 56
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;121 23 23&lt;BR /&gt;121 24 23&lt;BR /&gt;121 21 21&lt;BR /&gt;121 22 21&lt;BR /&gt;121 18 18&lt;BR /&gt;121 42 18&lt;BR /&gt;121 45 42&lt;BR /&gt;121 56 45&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 18:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612104#M178533</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2019-12-16T18:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612105#M178534</link>
      <description>&lt;P&gt;For future reference, saying it is "not working" never provides enough information for us to provide any help. What is not working? Please explain. Please provide details.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 18:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612105#M178534</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-16T18:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612114#M178539</link>
      <description>&lt;P&gt;If I've only total number of records is 6 , in this case i'm getting correct output. If I've more than 6 ....in my case i took 9 records... i'm not getting expected output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the output :&lt;/P&gt;&lt;P&gt;Subjid Num newvar&lt;/P&gt;&lt;P&gt;121 23 23&lt;BR /&gt;121 24 23&lt;BR /&gt;121 21 21&lt;BR /&gt;121 22 21&lt;BR /&gt;121 18 18&lt;BR /&gt;121 42 18&lt;BR /&gt;121 45 42&lt;BR /&gt;121 56 45&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expected output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subjid Num newvar&lt;/P&gt;&lt;P&gt;121 23 23&lt;BR /&gt;121 24 23&lt;BR /&gt;121 21 21&lt;BR /&gt;121 22 21&lt;BR /&gt;121 18 18&lt;BR /&gt;121 42 18&lt;BR /&gt;121 45 18&lt;BR /&gt;121 56 18&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 18:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612114#M178539</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2019-12-16T18:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612120#M178540</link>
      <description>&lt;P&gt;Looks like you want a running (cumulative) minimum.&amp;nbsp; But why doesn't the first observation have 23 as the minimum? Without that requirement it is really easy.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set t;
  newvar=min(newvar,num);
  retain newvar;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does your actual data have multiple values of SUBJID? Do you want to restart the min calculations when starting a new subject?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set t;
  by subjid ;
  newvar=min(newvar,num);
  if first.subjid then newvar=.;
  output;
  if first.subjid then newvar=num;
  retain newvar;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2019 18:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612120#M178540</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-16T18:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612121#M178541</link>
      <description>&lt;P&gt;In the code you provided earlier in message #3 in this thread, there are 8 input observations. My program produces 8 output observations, and is different than the output you show (and I think my code produces the correct answers).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, show your code.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 18:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612121#M178541</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-16T18:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612124#M178543</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153275"&gt;@singhsahab&lt;/a&gt;&amp;nbsp;Please change your subject line to a more &lt;U&gt;descriptive&lt;/U&gt; one. "Base SAS" means what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
input SUBJID Num;
datalines;
121 23
121 24
121 21
121 22
121 18
121 42
121 44
;
run; 

data want;
set t;
by subjid;
retain want;
if first.subjid then want=.;
want= min(want,num);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2019 18:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/612124#M178543</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-16T18:18:49Z</dc:date>
    </item>
  </channel>
</rss>

