<?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 How to split text into multiple variable with equal number of character in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580270#M13534</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a long text variable and I want to split this variables in multiple variables (v1 to Vn) with equal number of character in each variables. Of course, the last variable should has the left-over.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the example below, can you please help me to create variables with (10 letter and space) in each?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HHCFX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
    infile datalines dlm="|";

length var $ 30000;
input var $;
datalines;
&amp;lt;"myword myword: []/'\":+!@#$%&amp;amp; -0*&amp;amp;^% myword&amp;gt;&amp;lt;W15ySpnsrCW1sA5ZZ0&amp;lt;/W1urvA5ySpnsrCW1sA5ZZD&amp;gt;&amp;lt;W1:RA5prozzznmUnzzozMA5ozW1dW1ozW1&amp;gt;&amp;lt;W1:MA5oZozA5m&amp;gt;&amp;lt;/W1:MA5ozW1DW1ozW1Mrup&amp;gt;&amp;lt;W1:MA5ozW1DW1ozW1Mrup MA5ozW1DW1ozW1MrupNW1mA5="A5CW1SA5_CS_MW1"&amp;gt;&amp;lt;W1W1ozW1ZZ A5lA5mA5nozNW1mA5="WRKLW1D_OZYPA5_CDA5"&amp;gt;myword&amp;lt;/W1W1ozW1ZZoA5m&amp;gt;&amp;lt;W1W1ozW1ZZozA5m A5lA5mA5nozNW1mA5="WRKLW1D_P_OZYPA5_CDA5"&amp;gt;&amp;lt;/1W1ozW1ZZozA5m&amp;gt;&amp;lt;/W1:MA5ozW1DW1ozW1Mrup&amp;gt;&amp;lt;/W1:RA5prozzznmUnzzozMA5ozW1dW1ozW1&amp;gt;&amp;lt;WMW1zzlzznmW1ddrAW1ddr1&amp;gt;20OZ 11W1&amp;lt;/W1:W1ddr1&amp;gt;&amp;lt;W1:W1ddr3&amp;gt;NW1RRW1MW1NSA5OZOZ, RZZ -&amp;lt;/W1:W1ddr3&amp;gt;myword&lt;BR /&gt;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 13 Aug 2019 01:24:23 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2019-08-13T01:24:23Z</dc:date>
    <item>
      <title>How to split text into multiple variable with equal number of character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580270#M13534</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a long text variable and I want to split this variables in multiple variables (v1 to Vn) with equal number of character in each variables. Of course, the last variable should has the left-over.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the example below, can you please help me to create variables with (10 letter and space) in each?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HHCFX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
    infile datalines dlm="|";

length var $ 30000;
input var $;
datalines;
&amp;lt;"myword myword: []/'\":+!@#$%&amp;amp; -0*&amp;amp;^% myword&amp;gt;&amp;lt;W15ySpnsrCW1sA5ZZ0&amp;lt;/W1urvA5ySpnsrCW1sA5ZZD&amp;gt;&amp;lt;W1:RA5prozzznmUnzzozMA5ozW1dW1ozW1&amp;gt;&amp;lt;W1:MA5oZozA5m&amp;gt;&amp;lt;/W1:MA5ozW1DW1ozW1Mrup&amp;gt;&amp;lt;W1:MA5ozW1DW1ozW1Mrup MA5ozW1DW1ozW1MrupNW1mA5="A5CW1SA5_CS_MW1"&amp;gt;&amp;lt;W1W1ozW1ZZ A5lA5mA5nozNW1mA5="WRKLW1D_OZYPA5_CDA5"&amp;gt;myword&amp;lt;/W1W1ozW1ZZoA5m&amp;gt;&amp;lt;W1W1ozW1ZZozA5m A5lA5mA5nozNW1mA5="WRKLW1D_P_OZYPA5_CDA5"&amp;gt;&amp;lt;/1W1ozW1ZZozA5m&amp;gt;&amp;lt;/W1:MA5ozW1DW1ozW1Mrup&amp;gt;&amp;lt;/W1:RA5prozzznmUnzzozMA5ozW1dW1ozW1&amp;gt;&amp;lt;WMW1zzlzznmW1ddrAW1ddr1&amp;gt;20OZ 11W1&amp;lt;/W1:W1ddr1&amp;gt;&amp;lt;W1:W1ddr3&amp;gt;NW1RRW1MW1NSA5OZOZ, RZZ -&amp;lt;/W1:W1ddr3&amp;gt;myword&lt;BR /&gt;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Aug 2019 01:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580270#M13534</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-08-13T01:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to split text into multiple variable with equal number of character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580272#M13536</link>
      <description>&lt;P&gt;Can you also post the expected output?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 20:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580272#M13536</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-09T20:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to split text into multiple variable with equal number of character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580281#M13538</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm="|";
	length var $ 30000;
	input var $;
	datalines;
&amp;lt;b:ReportingUnit xmlns:a=""&amp;gt;&amp;lt;a:Bilingual&amp;gt;0&amp;lt;/a:Bilingual&amp;gt;&amp;lt;a:Cohort&amp;gt;3&amp;lt;/a:Cohort&amp;gt;&amp;lt;a:CONTACT_STRATEGY&amp;gt;1&amp;lt;/a:SolicitationData&amp;gt;&amp;lt;/b:ReportingUnit&amp;gt;
;
run;

data want;
	set have;
	length nvar1-nvar9 $10. nvar10 $100.;
	array nvar[*] $ nvar1-nvar10;
	j=1;

	do i=1 to 9;
		nvar[i]=cats(substrn(var,j,10),' ');
		j+10;
	end;

	j+10;
	nvar[i]=substrn(var,j);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is this what you are looking for ?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 21:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580281#M13538</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-08-09T21:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to split text into multiple variable with equal number of character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580283#M13539</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a long text variable and I want to split this variables in multiple variables (v1 to Vn) with equal number of character in each variables. Of course, the last variable should has the left-over.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the example below, can you please help me to create variables with (10 letter and space) in each?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HHCFX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
    infile datalines dlm="|";

length var $ 30000;
input var $;
datalines;
&amp;lt;b:ReportingUnit xmlns:a=""&amp;gt;&amp;lt;a:Bilingual&amp;gt;0&amp;lt;/a:Bilingual&amp;gt;&amp;lt;a:Cohort&amp;gt;3&amp;lt;/a:Cohort&amp;gt;&amp;lt;a:CONTACT_STRATEGY&amp;gt;1&amp;lt;/a:SolicitationData&amp;gt;&amp;lt;/b:ReportingUnit&amp;gt;
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;so with a defined length of 30000 are you asking to create 3,000 variables each holding 10 characters? Or in this case since your example string is 139 characters 14 variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And is your space supposed to be at the beginning of the variable? Trailing spaces generally don't mean much in SAS variables.&lt;/P&gt;
&lt;P&gt;One does wonder why the magic value of 10 letters and what having 3000 variables is for.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 21:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580283#M13539</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-09T21:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to split text into multiple variable with equal number of character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580287#M13540</link>
      <description>What about values that end up splitting a field? Is this ok:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Line 20: ......... &amp;lt;a: Bilingual&lt;BR /&gt;Line 21:&amp;gt;0&amp;lt;/a:Bilingual&amp;gt;&lt;BR /&gt;&lt;BR /&gt;Note where the 0 and closing &amp;gt; ends up.</description>
      <pubDate>Fri, 09 Aug 2019 22:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580287#M13540</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-09T22:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to split text into multiple variable with equal number of character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580349#M13548</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm="|";
	length var $ 30000;
	input var $;
	datalines4;
&amp;lt;b:ReportingUnit xmlns:a=""&amp;gt;&amp;lt;a:Bilingual&amp;gt;0&amp;lt;/a:Bilingual&amp;gt;&amp;lt;a:Cohort&amp;gt;3&amp;lt;/a:Cohort&amp;gt;&amp;lt;a:CONTACT_STRATEGY&amp;gt;1&amp;lt;/a:SolicitationData&amp;gt;&amp;lt;/b:ReportingUnit&amp;gt;
;;;;
run;

data temp;
 set have;
 n+1;
 length temp $ 4;
 do i=1 to length(var) by 4;
  temp=substr(var,i);
  output;
 end;
run;

proc print;run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Aug 2019 12:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-split-text-into-multiple-variable-with-equal-number-of/m-p/580349#M13548</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-08-10T12:11:07Z</dc:date>
    </item>
  </channel>
</rss>

