<?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: Data Manipulate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403493#M98053</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80618"&gt;@sijansap&lt;/a&gt;:&lt;/P&gt;&lt;P&gt;I think this does what you want:&lt;/P&gt;&lt;PRE&gt;data want;
  set have;
  array BI BI1-BI6;
  array severity(6) 8 _temporary_;
  do _N_=1 to 6;
    severity(_N_)=input(substr(BI(_N_),2),?? 1.); /* convert to numbers */
    end;
  _N_=whichn(max(of severity(*)),of severity(*)); /* Find first pos. of maximum */
  MaxBI=BI(_N_);
run;&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Oct 2017 11:00:34 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2017-10-12T11:00:34Z</dc:date>
    <item>
      <title>Data Manipulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403410#M98034</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;I got a situation. It is about body part injury and admission data. H being head, C being chest, A abdomen etc. 6 different body parts, and 1, 2, 3, and 4 being severity codes 1 being mild and 4 being severe. Each row is a case (or say admission to health center). These letter and number codes are combined together and has 20,000+ cases. I would like to select one letter code with highest severity code (number) and make one column say MaxBI (body part with maximum injury). Some of the cases don't have all 6 body injuries. Following is what I have:&lt;/P&gt;&lt;P&gt;Data have;&lt;/P&gt;&lt;P&gt;input $ BI1-BI6;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;H1&amp;nbsp;&amp;nbsp; C2 &amp;nbsp; F4&amp;nbsp;&amp;nbsp; A2&amp;nbsp;&amp;nbsp; G1&amp;nbsp;&amp;nbsp; E2&lt;/P&gt;&lt;P&gt;H3&amp;nbsp;&amp;nbsp; C1&amp;nbsp;&amp;nbsp; F2&amp;nbsp;&amp;nbsp; A4&amp;nbsp;&amp;nbsp; G2&amp;nbsp;&amp;nbsp; E1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C2&amp;nbsp;&amp;nbsp; F3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; G4&amp;nbsp;&amp;nbsp; E2&lt;/P&gt;&lt;P&gt;H4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F1 &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; E3&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Data Want: /*with MaxBI*/&lt;/P&gt;&lt;P&gt;H1&amp;nbsp;&amp;nbsp; C2 &amp;nbsp; F4&amp;nbsp;&amp;nbsp; A2&amp;nbsp;&amp;nbsp; G1&amp;nbsp;&amp;nbsp; E2&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F4&lt;/P&gt;&lt;P&gt;H2 &amp;nbsp; C1&amp;nbsp;&amp;nbsp; F2&amp;nbsp;&amp;nbsp; A3 &amp;nbsp; G2&amp;nbsp;&amp;nbsp; E1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C2&amp;nbsp;&amp;nbsp; F1 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; G3 &amp;nbsp; E2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; G3&lt;/P&gt;&lt;P&gt;H2 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F1 &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; E1 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H2 &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;I could split the letters and numbers from the first six columns using Substring function and take the Max of the substringed values, but I would not know which body part it came from. That is where I got stuck.&lt;/P&gt;&lt;P&gt;I would appreciate very much for your kind help.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Sijansap&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 01:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403410#M98034</guid>
      <dc:creator>sijansap</dc:creator>
      <dc:date>2017-10-12T01:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403428#M98036</link>
      <description>&lt;P&gt;You'll need to separate them. I would suggest two arrays, one with the numbers and one with the letters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can find the largest and whatever index it has will also be the corresponding body part.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 03:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403428#M98036</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-12T03:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403437#M98040</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;Thanks for the suggestion. I am not sure how I can make the two arrays you mentioned. I can make array for numbers, but not sure for the letters and to attach the highest number to the exact letter that came with originally. I apologize for being novice in array method.&lt;/P&gt;&lt;P&gt;I would appreciate if you could give me a bit more hint for the array layout for this awkward problem I am having.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Sijansap&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 03:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403437#M98040</guid>
      <dc:creator>sijansap</dc:creator>
      <dc:date>2017-10-12T03:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403438#M98041</link>
      <description>&lt;P&gt;1. Create an array for your original variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Create two other arrays, one for the letter, one for the numbers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Loop through and separate it using SUBSTR()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you've got that working, I can show you how to get the max with body part.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post your code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80618"&gt;@sijansap&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;Thanks for the suggestion. I am not sure how I can make the two arrays you mentioned. I can make array for numbers, but not sure for the letters and to attach the highest number to the exact letter that came with originally. I apologize for being novice in array method.&lt;/P&gt;
&lt;P&gt;I would appreciate if you could give me a bit more hint for the array layout for this awkward problem I am having.&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Sijansap&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 03:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403438#M98041</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-12T03:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403467#M98048</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data have;&lt;BR /&gt;input (BI1-BI6) ($);&lt;BR /&gt;cards;&lt;BR /&gt;H1 C2 F4 A2 G1 E2 F4&lt;BR /&gt;H2 C1 F2 A3 G2 E1 A3&lt;BR /&gt;C2 F1 G3 E2 G3 .&amp;nbsp; .&lt;BR /&gt;. . . H2 F1 E1 H2&lt;BR /&gt;;;;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp;set have;&lt;BR /&gt;&amp;nbsp;array aa {*} BI: ;&lt;BR /&gt;&amp;nbsp;max= 0;&lt;BR /&gt;&amp;nbsp;do i = 1 to dim(aa);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; num = input(compress(aa{i},'1234567890','k'),20.) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if num &amp;gt;=&amp;nbsp; max then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; idx = i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max = num;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;end;&lt;BR /&gt;&amp;nbsp;result = aa{idx};&lt;/P&gt;&lt;P&gt;&amp;nbsp;* drop max idx;&lt;BR /&gt;&amp;nbsp;Drop i;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 08:02:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403467#M98048</guid>
      <dc:creator>PSNn</dc:creator>
      <dc:date>2017-10-12T08:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403493#M98053</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80618"&gt;@sijansap&lt;/a&gt;:&lt;/P&gt;&lt;P&gt;I think this does what you want:&lt;/P&gt;&lt;PRE&gt;data want;
  set have;
  array BI BI1-BI6;
  array severity(6) 8 _temporary_;
  do _N_=1 to 6;
    severity(_N_)=input(substr(BI(_N_),2),?? 1.); /* convert to numbers */
    end;
  _N_=whichn(max(of severity(*)),of severity(*)); /* Find first pos. of maximum */
  MaxBI=BI(_N_);
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Oct 2017 11:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403493#M98053</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2017-10-12T11:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403511#M98057</link>
      <description>&lt;P&gt;This could also be done using the reverse function and call sortc.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=reverse:);
	set have;
	reverse_bi1=reverse(bi1);
	reverse_bi2=reverse(bi2);
	reverse_bi3=reverse(bi3);
	reverse_bi4=reverse(bi4);
	reverse_bi5=reverse(bi5);
	reverse_bi6=reverse(bi6);
	call sortc(of reverse_bi1-reverse_bi6);	
	maxbi=reverse(reverse_bi6);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Oct 2017 11:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403511#M98057</guid>
      <dc:creator>SuzanneDorinski</dc:creator>
      <dc:date>2017-10-12T11:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403611#M98081</link>
      <description>&lt;P&gt;Thank you all for your kind help in solving my problem.&amp;nbsp; Reeza's guide to array was educational. A bit long but PSNn's solution worked just fine. I also liked the simplified array by s_lassen. The easiest to&amp;nbsp;follow was with reverse function by SuzanneDorinski.&lt;/P&gt;&lt;P&gt;Again thank you all, I appreciate your time and help.&lt;/P&gt;&lt;P&gt;Sijansap&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;</description>
      <pubDate>Thu, 12 Oct 2017 16:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulate/m-p/403611#M98081</guid>
      <dc:creator>sijansap</dc:creator>
      <dc:date>2017-10-12T16:16:24Z</dc:date>
    </item>
  </channel>
</rss>

