<?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: Variable Creation Help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-Creation-Help/m-p/683752#M207121</link>
    <description>&lt;P&gt;It doesn't seem like transposing the data was helpful.&amp;nbsp; But you can still get what you want in this fashion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array dates {56} var1-var56;
do _n_=1 to 56;
   if year(dates{_n_}) = 2020 then earliest = min(earliest, dates{_n_});
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that the date variables really are dates, and not character strings.&amp;nbsp; Looking at your post, I'm suspicious, but you will have to check that and correct it if necessary.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Sep 2020 19:01:50 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2020-09-14T19:01:50Z</dc:date>
    <item>
      <title>Variable Creation Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Creation-Help/m-p/683697#M207105</link>
      <description>I am so sorry if this is too simple of a question, I have gone over SAS literature and can’t seem to find a good answer.&lt;BR /&gt;&lt;BR /&gt;I have some variables I have transposed in a data set. For some of my observations I have as many as 56 dates, so when I transpose I get 56 new variables.&lt;BR /&gt;&lt;BR /&gt;I am wanting to create a variable based off of the 56 variables created during the transpose process. I want to select the first date in 2020;&lt;BR /&gt;&lt;BR /&gt;So if var1 = 11/19/19&lt;BR /&gt;Var2= 1/3/20&lt;BR /&gt;Var3= 2/7/20&lt;BR /&gt;&lt;BR /&gt;The new variable would be 1/3/20.&lt;BR /&gt;&lt;BR /&gt;Is this possible?</description>
      <pubDate>Mon, 14 Sep 2020 15:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Creation-Help/m-p/683697#M207105</guid>
      <dc:creator>G-Scott</dc:creator>
      <dc:date>2020-09-14T15:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Creation Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Creation-Help/m-p/683702#M207109</link>
      <description>&lt;P&gt;&lt;FONT size="3" color="#000000"&gt;&lt;STRONG&gt;How about this?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="1"&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="1"&gt;&lt;FONT color="#0000ff"&gt;input&lt;/FONT&gt; obs date &lt;FONT color="#008080"&gt;date11.&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="1"&gt;&lt;FONT color="#0000ff"&gt;FORMAT&lt;/FONT&gt; DATE &lt;FONT color="#008080"&gt;DATE9.&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="1"&gt;&lt;FONT color="#0000ff"&gt;datalines&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="1"&gt;1 19/NOV/2019&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="1"&gt;2 03/JAN/2020&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="1"&gt;3 07/FEB/2020&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Option #1&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; date gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01jan2020'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=want &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=want_t;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; date;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT size="2"&gt;Option #2&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=have &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; date gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01jan2020'D&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; date;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; COL1 COL2 COL3 &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 16:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Creation-Help/m-p/683702#M207109</guid>
      <dc:creator>MelissaM</dc:creator>
      <dc:date>2020-09-14T16:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Creation Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Creation-Help/m-p/683703#M207110</link>
      <description>&lt;P&gt;You could use the MIN function in a DATA step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    newvariable=min(of var1-var56);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although I point out that transposing is not necessary in this case, PROC SUMMARY will find minimums from the un-transposed data.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 16:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Creation-Help/m-p/683703#M207110</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-14T16:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Creation Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Creation-Help/m-p/683752#M207121</link>
      <description>&lt;P&gt;It doesn't seem like transposing the data was helpful.&amp;nbsp; But you can still get what you want in this fashion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array dates {56} var1-var56;
do _n_=1 to 56;
   if year(dates{_n_}) = 2020 then earliest = min(earliest, dates{_n_});
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that the date variables really are dates, and not character strings.&amp;nbsp; Looking at your post, I'm suspicious, but you will have to check that and correct it if necessary.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 19:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Creation-Help/m-p/683752#M207121</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-09-14T19:01:50Z</dc:date>
    </item>
  </channel>
</rss>

