<?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 split a variable into 200 Character without chopping a word dynamically. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620119#M182173</link>
    <description>&lt;P&gt;Change the value of&amp;nbsp;devidingColumnLength variable on line 2 to 200, while running the code on your data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;
%let devidingColumnLength=10;  /*Change it to 200, 10 is taken for demonstration here*/

data IE;
input test:$2000.;
cards;
qwertyuopasdfghjkl02jiimddjj10jn
299302nhfmmmskskkkkkkkqieijncnc20099839kkjjj
sjjdjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjalllllllll1
kk
8
kkkkkkkkkkkkkkkkkkkkkkkkkkkk333333333333333330000000000000000000099
iii
;
run;

proc sql noprint;
select max(length(test)) into:maxLen from IE;
quit;

%put &amp;amp;=maxLen;

%macro runit;
data IE;
set IE;
%do i=1 %to %eval(&amp;amp;maxLen./&amp;amp;devidingColumnLength. + 1);
	%if &amp;amp;i=1 %then %do;
	init=1;
	%end;
	
	if length(test) ge init then do;
		TEST&amp;amp;i.=substr(test,init,&amp;amp;devidingColumnLength.);
		init=init+&amp;amp;devidingColumnLength.;
	end;
	else return;
%end;
drop init;
run;

%mend runit;
%runit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let us know if it worked for you.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jan 2020 07:35:10 GMT</pubDate>
    <dc:creator>Satish_Parida</dc:creator>
    <dc:date>2020-01-27T07:35:10Z</dc:date>
    <item>
      <title>How to split a variable into 200 Character without chopping a word dynamically.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620115#M182170</link>
      <description>&lt;P&gt;Hello everyone,,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a dataset of IE in that a variable TEST having greater than 200 Characters in some of its observation. I want those observation split into different variables having Length of 200 char.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 06:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620115#M182170</guid>
      <dc:creator>Florida1</dc:creator>
      <dc:date>2020-01-27T06:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable into 200 Character without chopping a word dynamically.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620119#M182173</link>
      <description>&lt;P&gt;Change the value of&amp;nbsp;devidingColumnLength variable on line 2 to 200, while running the code on your data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;
%let devidingColumnLength=10;  /*Change it to 200, 10 is taken for demonstration here*/

data IE;
input test:$2000.;
cards;
qwertyuopasdfghjkl02jiimddjj10jn
299302nhfmmmskskkkkkkkqieijncnc20099839kkjjj
sjjdjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjalllllllll1
kk
8
kkkkkkkkkkkkkkkkkkkkkkkkkkkk333333333333333330000000000000000000099
iii
;
run;

proc sql noprint;
select max(length(test)) into:maxLen from IE;
quit;

%put &amp;amp;=maxLen;

%macro runit;
data IE;
set IE;
%do i=1 %to %eval(&amp;amp;maxLen./&amp;amp;devidingColumnLength. + 1);
	%if &amp;amp;i=1 %then %do;
	init=1;
	%end;
	
	if length(test) ge init then do;
		TEST&amp;amp;i.=substr(test,init,&amp;amp;devidingColumnLength.);
		init=init+&amp;amp;devidingColumnLength.;
	end;
	else return;
%end;
drop init;
run;

%mend runit;
%runit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let us know if it worked for you.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 07:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620119#M182173</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2020-01-27T07:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable into 200 Character without chopping a word dynamically.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620124#M182177</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/309088"&gt;@Florida1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similar subject was answered earlier. It needs to change the size to 200.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/td-p/614640" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/td-p/614640&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 08:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620124#M182177</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2020-01-27T08:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable into 200 Character without chopping a word dynamically.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620141#M182183</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do you mean something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let split=20;

data have;
  var = "abcdefghihbuiuhfnjbvjzknoiewhfkbvzncldlwhflva"; output;
  var = "abcdefghihbuiuhfnjbvjz"; output;
  var = "abc"; output;
run;

data _null_;
if 0 then set have;
call symputx("varLen", vlength(var));
stop;
run;

%let numOfSplits=%sysevalf(&amp;amp;varLen./&amp;amp;split., CEIL);

%put &amp;amp;=split. &amp;amp;=varLen. &amp;amp;=numOfSplits.;

data want;
  set have;

  array v[&amp;amp;numOfSplits.] $ &amp;amp;split. ;

  j=0; drop i j;
  do i = 1 to min(&amp;amp;varLen.,lengthn(var)) by &amp;amp;split.;
   j+1;
   v[j] = substr(var, i);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 12:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620141#M182183</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-01-27T12:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable into 200 Character without chopping a word dynamically.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620195#M182205</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;: Bart, methinks it's more economical output-wise to base the splitting on the max LENGTH of the input VAR than on VLENGTH to avoid a bunch of empty trailing output VV's in case the system length &amp;gt;&amp;gt; actual max length. I.e., something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                                                                                                                                                                                                                     
  length var $ 100 ;                                                                                                                                                                                                                                            
  do var = "abcdefghihbuiuhfnjbvjzknoiewhfkbvzncldlwhflva"                                                                                                                                                                                                      
         , "abcdefghihbuiuhfnjbvjz"                                                                                                                                                                                                                             
         , "abc" ;                                                                                                                                                                                                                                              
    output ;                                                                                                                                                                                                                                                    
  end ;                                                                                                                                                                                                                                                         
run ;                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                
%let split = 20 ;                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                
proc sql noprint ;                                                                                                                                                                                                                                              
  select max (ceil (divide (length (var), &amp;amp;split))) into :ns from have ;                                                                                                                                                                                        
quit ;                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                
data want ;                                                                                                                                                                                                                                                     
  set have ;                                                                                                                                                                                                                                                    
  array vv [&amp;amp;ns] $ &amp;amp;split ;                                                                                                                                                                                                                                     
  do _n_ = 1 to &amp;amp;ns ;                                                                                                                                                                                                                                           
    vv[_n_] = substrn (var, (_n_ - 1) * &amp;amp;split + 1) ;                                                                                                                                                                                                           
  end ;                                                                                                                                                                                                                                                         
run ;          
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 15:31:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620195#M182205</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2020-01-27T15:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable into 200 Character without chopping a word dynamically.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620198#M182206</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pavle, that's why I've made it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 1 to min(&amp;amp;varLen.,lengthn(var)) by &amp;amp;split.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;so we have only 1 data read &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 15:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620198#M182206</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-01-27T15:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable into 200 Character without chopping a word dynamically.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620207#M182208</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pavle, I didn't get your point after first reading. Now I understood. You are 100% right, to wide array may be created without that additional pre-check.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 15:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620207#M182208</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-01-27T15:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable into 200 Character without chopping a word dynamically.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620218#M182213</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barteku, yup, that was my understanding. Fewer passes through the input is a noble goal. And I did realize that I was making an extra pass, just my angle was a bit different here, so I decided it was worth the sacrifice ;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 16:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-into-200-Character-without-chopping-a/m-p/620218#M182213</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2020-01-27T16:32:33Z</dc:date>
    </item>
  </channel>
</rss>

