<?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: Create a variable out of multiple with smallest value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516091#M139367</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
Input year_a   year_b   year_c    year_d   year_e;
cards;
. . 1990 . .
1979 1985 . . .
run;

data want;
	set have;
	array yr year_:;

	year=min(of yr(*));

	keep year;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 26 Nov 2018 19:24:09 GMT</pubDate>
    <dc:creator>r_behata</dc:creator>
    <dc:date>2018-11-26T19:24:09Z</dc:date>
    <item>
      <title>Create a variable out of multiple with smallest value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516085#M139363</link>
      <description>&lt;P&gt;I have 5 variables: year_a, year_b, year_c, year_d, year_e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For most of the observations, all but 1 are missing, but some have multiple years reported. I want to create a new variable year, that has the smallest year reported for years a-e. If anyone can walk me through the steps on how to do this (I assume this is an array, but I am not good with arrays yet) I would appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;year_a&amp;nbsp;&amp;nbsp; year_b&amp;nbsp;&amp;nbsp; year_c&amp;nbsp;&amp;nbsp;&amp;nbsp; year_d&amp;nbsp;&amp;nbsp; year_e&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1990&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;1979&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1985&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&lt;A href="https://communities.sas.com/t5/New-SAS-User/bd-p/new-users" target="_blank"&gt;&lt;SPAN class="cta-button"&gt;Ask your question&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;year&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1990&lt;/P&gt;&lt;P&gt;1979&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 19:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516085#M139363</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-11-26T19:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable out of multiple with smallest value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516086#M139364</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    min_year=min(year_a,year_b,year_c,year_d,year_e);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 19:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516086#M139364</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-26T19:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable out of multiple with smallest value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516091#M139367</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
Input year_a   year_b   year_c    year_d   year_e;
cards;
. . 1990 . .
1979 1985 . . .
run;

data want;
	set have;
	array yr year_:;

	year=min(of yr(*));

	keep year;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 19:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516091#M139367</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-11-26T19:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable out of multiple with smallest value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516094#M139368</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223452"&gt;@r_behata&lt;/a&gt;&amp;nbsp;why not&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	year=min(of year_:);
	keep year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't see the ARRAY adding any benefit here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I don't usually advise users to use the year_: syntax because I never know what other variables are in HAVE that begin with year_. Naturally, when you are programming your own code and you know the data sets, you will know that year_: refers only to the variables of interest (or not).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 19:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516094#M139368</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-26T19:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable out of multiple with smallest value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516147#M139381</link>
      <description>&lt;P&gt;Feeling bored, so tolerate me&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data have;
Input year_a   year_b   year_c    year_d   year_e;
cards;
. . 1990 . .
1979 1985 . . .
run;



data want;
set have;
min_year=smallest(1,of year_:);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 21:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-out-of-multiple-with-smallest-value/m-p/516147#M139381</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-26T21:31:49Z</dc:date>
    </item>
  </channel>
</rss>

