<?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: Horizontal processing of a dataset? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293366#M61043</link>
    <description>&lt;P&gt;Actually, you'd be better of with a long instead of a wide data format; a wide format "hides" data in the structure (variable names), making coding unnecessarily difficult.&lt;/P&gt;
&lt;P&gt;Consider a dataset that has only acct_num, month and status:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=have (where=(status='E'))
  out=temp (drop=status)
;
by acct_num descending month;
run;

data want (rename=(month=last_hit_e));
set temp;
by acct_num;
if first.acct_num;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's understood that "month" should be a proper SAS date variable, of course. &lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2016 07:45:59 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-08-23T07:45:59Z</dc:date>
    <item>
      <title>Horizontal processing of a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293267#M60982</link>
      <description>&lt;P&gt;/*I have this dataset. It has 6 accounts. It shows how the succession of the status of each acct has happened over&lt;/P&gt;&lt;P&gt;a period of 6 months*/&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; have;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; acct_num status_Jan $&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;5&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; status_feb $&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;6&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;7&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; status_Mar $&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;8&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;9&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; status_apr $&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;10&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; status_May $&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;13&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; status_Jun $&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;14&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;15&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;cards&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;111 7 . 1 5 E 1&lt;/P&gt;&lt;P&gt;222 7 7 7 7 1 .&lt;/P&gt;&lt;P&gt;333 7 E 1 E 1 1&lt;/P&gt;&lt;P&gt;444 7 7 1 . . .&lt;/P&gt;&lt;P&gt;555 7 . . . . 1&lt;/P&gt;&lt;P&gt;666 7 . . . . .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;/*Q: I wanted to create a new variable which shows what is the month each acct last ever hit "E" status.&lt;/P&gt;&lt;P&gt;For example, acct 111 has last hit "E" status in May. Acct 333 has last hit "E" status in April.&lt;/P&gt;&lt;P&gt;So, the new variable called "last_hit_E" should return May for acct 111 and should return April for acct 333&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;/*&lt;/P&gt;&lt;P&gt;Answer table should be like below.&lt;/P&gt;&lt;P&gt;acct_num status_Jan status_feb status_Mar status_apr status_May status_Jun last_hit_E&lt;/P&gt;&lt;P&gt;111 7 . 1 5 E 1 May&lt;/P&gt;&lt;P&gt;222 7 7 7 7 1 . .&lt;/P&gt;&lt;P&gt;333 7 E 1 E 1 1 April&lt;/P&gt;&lt;P&gt;444 7 7 1 . . . .&lt;/P&gt;&lt;P&gt;555 7 . . . . 1 .&lt;/P&gt;&lt;P&gt;666 7 . . . . . .&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;/*Could someone help me to create the "last_hit_E" variable.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Mirisa*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 21:15:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293267#M60982</guid>
      <dc:creator>dunga</dc:creator>
      <dc:date>2016-08-22T21:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal processing of a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293269#M60983</link>
      <description>&lt;P&gt;Create an array and loop backwards through it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array month_vars(6) status_;
do i=dim(month_vars) to 1 by -1;
***code;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 21:30:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293269#M60983</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-22T21:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal processing of a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293293#M60997</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array month(*) status_:;
&lt;STRONG&gt;do i = 1 to dim(month);
if month(i)='E' then new=scan(vname(month(i)),2,'_');
end;&lt;/STRONG&gt;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 01:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293293#M60997</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-08-23T01:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal processing of a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293366#M61043</link>
      <description>&lt;P&gt;Actually, you'd be better of with a long instead of a wide data format; a wide format "hides" data in the structure (variable names), making coding unnecessarily difficult.&lt;/P&gt;
&lt;P&gt;Consider a dataset that has only acct_num, month and status:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=have (where=(status='E'))
  out=temp (drop=status)
;
by acct_num descending month;
run;

data want (rename=(month=last_hit_e));
set temp;
by acct_num;
if first.acct_num;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's understood that "month" should be a proper SAS date variable, of course. &lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 07:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293366#M61043</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-23T07:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal processing of a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293370#M61046</link>
      <description>&lt;P&gt;Its pretty much exactly the same (question) logic as given in your other question here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Data-rule-for-horizontal-records/m-p/293192#M60952" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Data-rule-for-horizontal-records/m-p/293192#M60952&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Except change missing to E.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 08:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293370#M61046</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-23T08:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal processing of a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293516#M61100</link>
      <description>&lt;P&gt;Hi Reeza, Jega, Kurt and RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks to each one of you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mirisa&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 18:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-processing-of-a-dataset/m-p/293516#M61100</guid>
      <dc:creator>dunga</dc:creator>
      <dc:date>2016-08-23T18:02:43Z</dc:date>
    </item>
  </channel>
</rss>

