<?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: Character variables with varying number of &amp;quot;words&amp;quot; and how to parse them correctly in new variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28515#M6626</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; combining Art ant Tom's methods:&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; VAR0 &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: teal; font-size: 12pt;"&gt;$40.&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;ABC_F_P_LOW&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;DEF_K__HIGH&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;ZPQ_M_X_MEDIUM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;GKL_J_B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v{&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;} $ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; _n_=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;&amp;nbsp; v{_n_}=scan(tranwrd(var0,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'__'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'_ _'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;),_n_,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'_'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt;;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; obs&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR0&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; v1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v2&amp;nbsp;&amp;nbsp;&amp;nbsp; v3&amp;nbsp;&amp;nbsp;&amp;nbsp; v4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC_F_P_LOW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOW&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEF_K__HIGH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEF&amp;nbsp;&amp;nbsp;&amp;nbsp; K&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HIGH&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ZPQ_M_X_MEDIUM&amp;nbsp;&amp;nbsp;&amp;nbsp; ZPQ&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MEDIUM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GKL_J_B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GKL&amp;nbsp;&amp;nbsp;&amp;nbsp; J&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Mar 2012 18:11:27 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2012-03-12T18:11:27Z</dc:date>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28501#M6612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable with character values as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;VAR0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ABC_F_P_LOW&lt;/P&gt;&lt;P&gt;DEF_K_HIGH&lt;/P&gt;&lt;P&gt;ZPQ_M_X_MEDIUM&lt;/P&gt;&lt;P&gt;GKL_J_B&lt;/P&gt;&lt;P&gt;.....................&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to create four new variables as:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;V1&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V2&amp;nbsp; V3&amp;nbsp;&amp;nbsp;&amp;nbsp; V4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ABC&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOW&lt;/P&gt;&lt;P&gt;DEF&amp;nbsp;&amp;nbsp; K&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HIGH&lt;/P&gt;&lt;P&gt;ZPQ&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&amp;nbsp;&amp;nbsp;&amp;nbsp; MEDIUM&lt;/P&gt;&lt;P&gt;GKL&amp;nbsp;&amp;nbsp; J&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;&lt;P&gt;.................................&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried certain Character Functions but they do not position correctly the "words" in the right new created variable (i.e. HIGH goes to V3 while it should go to V4).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would appreciate any suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nikos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 06:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28501#M6612</guid>
      <dc:creator>Nikos</dc:creator>
      <dc:date>2012-03-12T06:48:45Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28502#M6613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK.&lt;/P&gt;&lt;P&gt;But I think you should post some more data to clarify your question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data x;
input VAR0 $40.;
cards;
ABC_F_P_LOW
DEF_K_HIGH
ZPQ_M_X_MEDIUM
GKL_J_B
;
run;
data want(drop=temp i);
 set x;
 array v{4} $ ;
 do i=1 to 4;
&amp;nbsp; temp=scan(var0,i,'_');
&amp;nbsp; if temp not in ('LOW' 'HIGH' 'MEDIUM' ' ' )&amp;nbsp; then v{i}=temp;
&amp;nbsp;&amp;nbsp; else if not missing(temp) then v{4}=temp;
 end;
run;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 08:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28502#M6613</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-03-12T08:14:31Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28503#M6614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is only about assigning the terms Low, Medium, High to the 4th variable then Ksharp provided you with a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there are also other "strings" which need to be assigned to specific variables then you would have to tell us a bit more what the rule should be to decide which "word" goes where - or you need an exhaustive list of words togethere with the place they should go (kind of a key/value pair list).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 09:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28503#M6614</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-03-12T09:37:00Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28504#M6615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nikos, you have to clarify your rules.&amp;nbsp; Just in your example, you have high going to V4, but B going to V3.&amp;nbsp; Why?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 12:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28504#M6615</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-12T12:17:07Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28505#M6616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nikos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As others have noted, KSharp's solution is a good one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are a few situations that you may have to address ... it depends on what your data contains.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible that the third word (or even the first or second word) could also contain HIGH / MEDIUM / LOW:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABC_F_LOW_LOW&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In that case, how would you know how to parse this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABC_F_LOW&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should LOW definitely become V4, or is it possible it could become V3?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know enough about the data to assign shorter lengths to V1-V4?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The answers may be very easy, but you're the only one who would know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 13:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28505#M6616</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-03-12T13:14:38Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28506#M6617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You were right. The particular value sould read DEF_K__HIGH meaning that the third "word" is missing and HIGH should be placed under V4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The rule is that each "word" is positioned under a new variable based only on its place in the initial variable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The word before the first "_" goes to VAR1, the "word" between the first "_" and the second "_" goes to the second variable V2, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there are two "_" in a row then missing goes to the respective New Variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nikos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 14:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28506#M6617</guid>
      <dc:creator>Nikos</dc:creator>
      <dc:date>2012-03-12T14:43:53Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28507#M6618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nikos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems to me that there is NO two '_' in a row addressed by your first post.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 14:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28507#M6618</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-12T14:48:22Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28508#M6619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nikos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then all you need is the "M" modifier in your scan.&amp;nbsp; e.g., borrowing from Ksharp's code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data x;&lt;/P&gt;&lt;P&gt;input VAR0 $40.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;ABC_F_P_LOW&lt;/P&gt;&lt;P&gt;DEF_K__HIGH&lt;/P&gt;&lt;P&gt;ZPQ_M_X_MEDIUM&lt;/P&gt;&lt;P&gt;GKL_J_B&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(drop=temp i);&lt;/P&gt;&lt;P&gt; set x;&lt;/P&gt;&lt;P&gt; array v{4} $ ;&lt;/P&gt;&lt;P&gt; do i=1 to 4;&lt;/P&gt;&lt;P&gt;&amp;nbsp; temp=scan(var0,i,'_',"M");&lt;/P&gt;&lt;P&gt;&amp;nbsp; if not missing(temp) then v{i}=temp;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 14:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28508#M6619</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-12T14:52:24Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28509#M6620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That was a mistatement of mine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 14:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28509#M6620</guid>
      <dc:creator>Nikos</dc:creator>
      <dc:date>2012-03-12T14:52:57Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28510#M6621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Art,&lt;/P&gt;&lt;P&gt;are there any difference between &lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; want(drop=temp i);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v{&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;} $ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;&amp;nbsp; temp=scan(var0,i,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'_'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;"M"&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; not missing(temp) &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v{i}=temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt;;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; want(drop=i);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v{&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;} $ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;&amp;nbsp; v{i}=scan(var0,i,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'_'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;"M"&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green; font-size: 12pt;"&gt;*if not missing(temp) then v{i}=temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt;;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;Thanks - Linlin&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 15:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28510#M6621</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-03-12T15:24:03Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28511#M6622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Linlin,&amp;nbsp; Yes there is!&amp;nbsp; The way you programmed it is more efficient!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 15:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28511#M6622</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-12T15:49:55Z</dc:date>
    </item>
    <item>
      <title>Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28512#M6623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately SCAN with "M" modifier works under SAS 9.2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I still work with SAS 9.1.3 I would appreciate any workaround.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nikos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 17:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28512#M6623</guid>
      <dc:creator>Nikos</dc:creator>
      <dc:date>2012-03-12T17:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28513#M6624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here are two options.&lt;/P&gt;&lt;P&gt;1) Use TRANWRD to stick a space between the adjacent underscores.&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;x= tranwrd(x,'__','_ _');
word1=scan(x,1,'_');
...&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Use the _INFILE_ trick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile cards dsd dlm='_' truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until(eof);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set old end=eof;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _infile_=x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @1 (word1-word4) ($) @;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;stop;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;junk line&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 17:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28513#M6624</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-12T17:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28514#M6625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One possible solution is to reverse back to your raw data, and utilize 'infile' options:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data x;&lt;/P&gt;&lt;P&gt;infile cards dsd dlm='_' missover;&lt;/P&gt;&lt;P&gt;input (var1-var4) (:$);&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;ABC_F_P_LOW&lt;/P&gt;&lt;P&gt;DEF_K__HIGH&lt;/P&gt;&lt;P&gt;ZPQ_M_X_MEDIUM&lt;/P&gt;&lt;P&gt;GKL_J_B&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 17:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28514#M6625</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-12T17:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28515#M6626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; combining Art ant Tom's methods:&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; VAR0 &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: teal; font-size: 12pt;"&gt;$40.&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;ABC_F_P_LOW&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;DEF_K__HIGH&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;ZPQ_M_X_MEDIUM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;GKL_J_B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; v{&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;} $ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt; _n_=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;&amp;nbsp; v{_n_}=scan(tranwrd(var0,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'__'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'_ _'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;),_n_,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 12pt;"&gt;'_'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 12pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt;;&lt;STRONG style="color: navy; font-size: 12pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; obs&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR0&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; v1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v2&amp;nbsp;&amp;nbsp;&amp;nbsp; v3&amp;nbsp;&amp;nbsp;&amp;nbsp; v4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC_F_P_LOW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOW&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEF_K__HIGH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEF&amp;nbsp;&amp;nbsp;&amp;nbsp; K&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HIGH&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ZPQ_M_X_MEDIUM&amp;nbsp;&amp;nbsp;&amp;nbsp; ZPQ&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MEDIUM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'SAS Monospace'; font-size: 8pt;"&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; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GKL_J_B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GKL&amp;nbsp;&amp;nbsp;&amp;nbsp; J&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 18:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28515#M6626</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-03-12T18:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Character variables with varying number of "words" and how to parse them correctly in new variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28516#M6627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'@' is added to your first input statement, and it runs perfect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data old;&lt;/P&gt;&lt;P&gt;input VAR0 $40.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;ABC_F_P_LOW&lt;/P&gt;&lt;P&gt;DEF_K__HIGH&lt;/P&gt;&lt;P&gt;ZPQ_M_X_MEDIUM&lt;/P&gt;&lt;P&gt;GKL_J_B&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile cards dsd dlm='_' truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until(eof);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set old end=eof;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _infile_=var0;&lt;/P&gt;&lt;P&gt; put 'infile=' _infile_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @1 (word1-word4) ($) @;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;stop;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;junk line&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 18:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-variables-with-varying-number-of-quot-words-quot-and/m-p/28516#M6627</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-12T18:25:58Z</dc:date>
    </item>
  </channel>
</rss>

