<?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: how to deal with these data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422104#M103791</link>
    <description>&lt;P&gt;Thansk for the reply. But the&amp;nbsp; case is not always right.&amp;nbsp; Those beginning with "I " are questions and not always begin with "I". Some with "I", some with "N", some with "M".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Dec 2017 19:30:47 GMT</pubDate>
    <dc:creator>daisy6</dc:creator>
    <dc:date>2017-12-18T19:30:47Z</dc:date>
    <item>
      <title>how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422095#M103786</link>
      <description>&lt;P&gt;Hi, I have a data set like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data test;&lt;BR /&gt;input name $10. rate 2. ;&lt;BR /&gt;datalines;&lt;BR /&gt;I12345&amp;nbsp; &amp;nbsp; &amp;nbsp;2.3&lt;BR /&gt;0.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.2&lt;BR /&gt;0.2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.6&lt;BR /&gt;0.3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.5&lt;BR /&gt;0.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.4&lt;BR /&gt;I23456&amp;nbsp; &amp;nbsp; 3.4&lt;BR /&gt;0.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.3&lt;BR /&gt;0.2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.8&lt;BR /&gt;0.3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.4&lt;BR /&gt;0.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1.5&lt;BR /&gt;I34567&amp;nbsp; &amp;nbsp; &amp;nbsp; 2.6&lt;BR /&gt;0.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.2&lt;BR /&gt;0.2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.5&lt;BR /&gt;0.3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.6&lt;BR /&gt;0.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1.7&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the data set like:&lt;/P&gt;&lt;P&gt;name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rate&lt;/P&gt;&lt;P&gt;I12345&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2.3&lt;BR /&gt;&lt;SPAN&gt;I12345A&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; 1.2&lt;BR /&gt;&lt;SPAN&gt;I12345B&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;1.6&lt;BR /&gt;&lt;SPAN&gt;I12345C&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;1.5&lt;BR /&gt;&lt;SPAN&gt;I12345D&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;1.4&lt;BR /&gt;I23456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.4&lt;BR /&gt;&lt;SPAN&gt;I23456A&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt; 2.3&lt;BR /&gt;&lt;SPAN&gt;I23456B&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; 1.8&lt;BR /&gt;&lt;SPAN&gt;I23456C&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;1.4&lt;BR /&gt;&lt;SPAN&gt;I23456D&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; 1.5&lt;BR /&gt;I34567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.6&lt;BR /&gt;&lt;SPAN&gt;I34567A&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt; 1.2&lt;BR /&gt;&lt;SPAN&gt;I34567B&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;1.5&lt;BR /&gt;&lt;SPAN&gt;I34567C&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;1.6&lt;BR /&gt;&lt;SPAN&gt;I34567D&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;1.7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any idea.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 19:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422095#M103786</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-12-18T19:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422101#M103789</link>
      <description>&lt;P&gt;Every time you encounter a name that begins with uppercase "I", you want to retain that value as a&amp;nbsp; name root.&amp;nbsp; For subsequent observations you want name to have that name root, with consecutive suffixes of "A", "B", "C", etc:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input name :$10. rate  ;
datalines;
I12345     2.3
0.1          1.2
0.2          1.6
0.3          1.5
0.4          1.4
I23456    3.4
0.1          2.3
0.2          1.8
0.3          1.4
0.4           1.5
I34567      2.6
0.1            1.2
0.2            1.5
0.3            1.6
0.4             1.7
;
run;

data want (drop=i name_root);
  set test;
  length name_root $10;
  retain name_root;
  array suffix {8} $1 _temporary_ (' ','A','B','C','D','E','F','G');
  i+1;
  if name=: 'I' then do;
     i=1;
    name_root=name;
  end;

  name=cats(name_root,suffix{i});
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The "=:" comparison operator takes the shortest character operand, and determines whether that matches the beginning of the longer operant.&amp;nbsp; So&amp;nbsp;&amp;nbsp; "if name=: 'I' asks whether name starts with an "I".&lt;/LI&gt;
&lt;LI&gt;The temporary array suffix has initial values.&amp;nbsp; Notes the first initial values is a blank, so when I=1&amp;nbsp; (when a new root is found) the cats functions appends a blank,&amp;nbsp; for I=2 it's an "A", etc.&amp;nbsp; If you expect more than 8 cases with the same root, make the suffix array bigger, with more initial values.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 18 Dec 2017 19:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422101#M103789</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-12-18T19:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422102#M103790</link>
      <description>&lt;P&gt;Try using a format&amp;nbsp;and then keep any oldname that doesn't begin with a zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value $append '0.1' = 'A'
                 '0.2' = 'B'
                 '0.3' = 'C'
                 '0.4' = 'D';
run;

data test2;
   set test(rename=(name=oldname));
   retain last_name;

   if oldname^=:'0' then do;
      name=oldname;
      last_name=oldname;
   end;
   else name = strip(last_name)||put(oldname,$append.);

   drop last_name oldname;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 19:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422102#M103790</guid>
      <dc:creator>antonbcristina</dc:creator>
      <dc:date>2017-12-18T19:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422104#M103791</link>
      <description>&lt;P&gt;Thansk for the reply. But the&amp;nbsp; case is not always right.&amp;nbsp; Those beginning with "I " are questions and not always begin with "I". Some with "I", some with "N", some with "M".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 19:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422104#M103791</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-12-18T19:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422105#M103792</link>
      <description>&lt;P&gt;Thanks for the idea. However, my data not always begin with "I'. It depends on the exam. Different exam has a different suffix. I want a general code to apply&amp;nbsp;all kinds of&amp;nbsp;exams&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 19:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422105#M103792</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-12-18T19:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422107#M103793</link>
      <description>&lt;P&gt;I saw your comment and added in the:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if oldname^=:'0' then do;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Dec 2017 19:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422107#M103793</guid>
      <dc:creator>antonbcristina</dc:creator>
      <dc:date>2017-12-18T19:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422110#M103794</link>
      <description>&lt;P&gt;I test you code and it works. Thank you very much,&amp;nbsp;Merry Christmas!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 19:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422110#M103794</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-12-18T19:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422112#M103795</link>
      <description>&lt;P&gt;You already have an answer but, if the value (rather than order) of name determines the letter value assigned, I would suggest something like:&lt;/P&gt;
&lt;PRE&gt;data test;
  input name :$10. rate  ;
  datalines;
I12345     2.3
0.1          1.2
0.2          1.6
0.3          1.5
0.4          1.4
M23456    3.4
0.1          2.3
0.2          1.8
0.3          1.4
0.4           1.5
N34567      2.6
0.1            1.2
0.2            1.5
0.3            1.6
0.4             1.7
;
run;

data want (drop=name_root);
  set test;
  length name_root $10;
  retain name_root;
  if anyalpha(name) then do;
    name_root=name;
    name=-3.2;
  end;
  name=cats(name_root,byte(name*10+64));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 21:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422112#M103795</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-18T21:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422116#M103798</link>
      <description>&lt;P&gt;If you need something even fancier, you can try using Perl Regular Expressions to capture the pattern of your expected names. In this case, I just tried to match a non-digit (\D) followed by one or more digits (\d?). prxmatch returns the position where the pattern is found, and we would like it to start in position one.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   if prxmatch('/\D\d?/',oldname)=1 then do;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Dec 2017 19:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422116#M103798</guid>
      <dc:creator>antonbcristina</dc:creator>
      <dc:date>2017-12-18T19:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422131#M103799</link>
      <description>&lt;P&gt;Hi Art,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your solution appends an '8' to the name when anyalpha(name)=TRUE. For these cases, I would suggest&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    name=-3.2;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;so that you're appending a space.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 20:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422131#M103799</guid>
      <dc:creator>antonbcristina</dc:creator>
      <dc:date>2017-12-18T20:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with these data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422138#M103802</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84234"&gt;@antonbcristina&lt;/a&gt;: thanks for catching that. I've changed it in my suggested code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 21:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-deal-with-these-data/m-p/422138#M103802</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-18T21:06:30Z</dc:date>
    </item>
  </channel>
</rss>

