<?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: Convert columns of text strings into separated variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788802#M252306</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;for that suggestion.&amp;nbsp; Haven't yet run ODS Trace.&amp;nbsp; Good idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, for the moment, I went about it the long way, taking the Proc HPSplit listing output, and converting it to a seemingly usable dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The key now is to try to logically consider what exactly I have.&amp;nbsp; Not really a programming conundrum.&amp;nbsp; A tricky puzzle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jan 2022 06:02:23 GMT</pubDate>
    <dc:creator>NKormanik</dc:creator>
    <dc:date>2022-01-07T06:02:23Z</dc:date>
    <item>
      <title>Convert columns of text strings into separated variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788235#M251964</link>
      <description>&lt;P&gt;Following suggestions from yesterday's question, we have converted a single long column of text to four text strings across -- a text string in each of four columns, 1000 rows of such.&amp;nbsp; In image below, 'a' is a text string, etc.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4 across 1.png" style="width: 162px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67100iC95D20F8B54E2985/image-size/large?v=v2&amp;amp;px=999" role="button" title="4 across 1.png" alt="4 across 1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The actual context is more the following:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4 across 2.png" style="width: 485px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67101i97E524308FF37C46/image-size/large?v=v2&amp;amp;px=999" role="button" title="4 across 2.png" alt="4 across 2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The next step is to separate out the individual strings -- composed of numbers and characters.&amp;nbsp; Each and every string has the same components.&amp;nbsp; The components separated by a single space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After the conversion, based on the above image, there will be 3x4=12 variables. 'a' and 'm' will make up the first two observations in variable, say, COL1.1.&amp;nbsp; 'b' and 'n' --&amp;gt; COL1.2.&amp;nbsp; &amp;nbsp;. . .&amp;nbsp; &amp;nbsp;'l' and 'x' --&amp;gt; COL4.3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, the question to the community is how to code this transition?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before the four-across conversion, it was a simple matter to import the single column of text strings, from a text file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sas_1.importance_long;
infile "C:\2\Importance, Long.txt";
input
Indicator $10. Relative Importance Count NSurrog;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the present case I'm hoping not to have to send the entire lot out to a text file, just to have to then import it back into SAS.&amp;nbsp; Although I'm completely amenable to doing that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any thoughts appreciated!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 07:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788235#M251964</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2022-01-04T07:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns of text strings into separated variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788239#M251967</link>
      <description>&lt;P&gt;Let me paraphrase classic: "Use the array Nicholas":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  col1 = "A B C";
run;

%let size = 3;
%let length = 12;

data want;
  set have;

  array col1_[&amp;amp;size.] $ &amp;amp;length.;

  do _N_ = 1 to &amp;amp;size.;
    col1_[_N_]  = scan(col1, _N_, " ");
  end;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 08:32:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788239#M251967</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-01-04T08:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns of text strings into separated variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788254#M251981</link>
      <description>&lt;P&gt;You want this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards dlm=',';
input (col1-col4) ($);
cards;
a b c,d e f,g h i,j k l
m n o,p q r,s t u,v w x
;


proc iml;
use have;
read all var _char_ into have;
close;

want=cshape(compress(have),0,12,1,' ');
print want;

create want from want;
append from want;
close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jan 2022 11:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788254#M251981</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-04T11:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns of text strings into separated variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788760#M252280</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;, You both seem to be from a different planet.&amp;nbsp; Certainly NOT the Earth that I'm aware of.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a million for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 01:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788760#M252280</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2022-01-07T01:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns of text strings into separated variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788764#M252282</link>
      <description>&lt;P&gt;Why did you convert the original into 4 instead of 12?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 01:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788764#M252282</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-07T01:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns of text strings into separated variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788767#M252284</link>
      <description>&lt;P&gt;The original 4 I didn't convert, but shifted over and up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After the shifting, I needed to convert the 12 to variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Original SAS output from HPSplit (more to the far right):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID       Path                                                    Count   Success         Fail

0        Root Node                                                3900    0.8244    *    0.1756
1        Root Node                                                3900    0.8244         0.1756
         i_22304_Z &amp;lt; 0.621804 or Missing                          2948    0.8457    *    0.1543
2        Root Node                                                3900    0.8244         0.1756
         i_22304_Z &amp;gt;= 0.621804                                     952    0.7584    *    0.2416
3        Root Node                                                3900    0.8244         0.1756
         i_22304_Z &amp;lt; 0.621804 or Missing                          2948    0.8457         0.1543
         i_21603_Z &amp;lt; -1.27055                                      496    0.7601    *    0.2399
4        Root Node                                                3900    0.8244         0.1756
         i_22304_Z &amp;lt; 0.621804 or Missing                          2948    0.8457         0.1543
         i_21603_Z &amp;gt;= -1.27055 or Missing                         2452    0.8630    *    0.1370
5        Root Node                                                3900    0.8244         0.1756
         i_22304_Z &amp;gt;= 0.621804                                     952    0.7584         0.2416
         i_21104_Z &amp;lt; 0.385132 or Missing                           522    0.8218    *    0.1782
6        Root Node                                                3900    0.8244         0.1756
         i_22304_Z &amp;gt;= 0.621804                                     952    0.7584         0.2416
         i_21104_Z &amp;gt;= 0.385132                                     430    0.6814    *    0.3186&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After successfully editing out extra unwanted 'strings', and shifting:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-01-06 18_59_49-SAS Universal Viewer - [c__0 desktops_06_desktop_parameters_long_merge_4_across..png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67170i308A9DFA9BD32EBB/image-size/large?v=v2&amp;amp;px=999" role="button" title="2022-01-06 18_59_49-SAS Universal Viewer - [c__0 desktops_06_desktop_parameters_long_merge_4_across..png" alt="2022-01-06 18_59_49-SAS Universal Viewer - [c__0 desktops_06_desktop_parameters_long_merge_4_across..png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Then four-across:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-01-06 19_06_06-SAS Universal Viewer - [c__0 desktops_06_desktop_parameters_long_four_across.sas.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67171i0C13A2DADF649134/image-size/large?v=v2&amp;amp;px=999" role="button" title="2022-01-06 19_06_06-SAS Universal Viewer - [c__0 desktops_06_desktop_parameters_long_four_across.sas.png" alt="2022-01-06 19_06_06-SAS Universal Viewer - [c__0 desktops_06_desktop_parameters_long_four_across.sas.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;At this point, while feeling I'm on track, I need to interpret what it actually means.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example of a good split (graph produced by HPSplit):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-01-06 19_12_14-C__0 Desktops_06_Desktop_First Cut Decision Tree - Copy_First Cut Long_00002.png.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67172i630BC6CB5D032917/image-size/large?v=v2&amp;amp;px=999" role="button" title="2022-01-06 19_12_14-C__0 Desktops_06_Desktop_First Cut Decision Tree - Copy_First Cut Long_00002.png.png" alt="2022-01-06 19_12_14-C__0 Desktops_06_Desktop_First Cut Decision Tree - Copy_First Cut Long_00002.png.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;On the right the number 0.8563 represents 'Success', based on variable i_22801, parameter being &amp;gt;= -2.379.&amp;nbsp; The success rate can be further increased by additionally using variable i_21501a, with parameter value &amp;gt;= 0.566.&amp;nbsp; Percentage success in that branch rises to 89.19%.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The challenge is to interpret, wrap it all up, and come to some conclusion as to the best course of action.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 02:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788767#M252284</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2022-01-07T02:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns of text strings into separated variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788775#M252286</link>
      <description>&lt;P&gt;Are you saying you are trying to parse the listing output of the proc?&amp;nbsp; Doesn't it produce any actual datasets you can use?&amp;nbsp; Did you try running with ODS TRACE&amp;nbsp; on to at least see if there might be an ODS output you could capture as a dataset?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 02:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788775#M252286</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-07T02:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns of text strings into separated variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788802#M252306</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;for that suggestion.&amp;nbsp; Haven't yet run ODS Trace.&amp;nbsp; Good idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, for the moment, I went about it the long way, taking the Proc HPSplit listing output, and converting it to a seemingly usable dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The key now is to try to logically consider what exactly I have.&amp;nbsp; Not really a programming conundrum.&amp;nbsp; A tricky puzzle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 06:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-columns-of-text-strings-into-separated-variables/m-p/788802#M252306</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2022-01-07T06:02:23Z</dc:date>
    </item>
  </channel>
</rss>

