<?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 name string with no delimiters into columns/variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621800#M19655</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294186"&gt;@Rakesh93&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is a way to achieve this, using pearl regular expressions.&lt;/P&gt;
&lt;P&gt;NB: the proc sql step enables you not to specify arbitrary 4 as the maximum count of words.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input name $80.;
	datalines;
DineshReddy
RajeshRaoReddy
PraveenKumarRaoKumar
;
run;

data have1;
	set have;
	_name= prxchange('s/([A-Z])/ $1/',-1,name);
run;

proc sql noprint;
	select max(countw(_name)) into:nb_max from have1;
quit;

data want;
	set have1;
	array var(&amp;amp;nb_max) $20.;
	do i=1 to countw(_name);
		var(i)=scan(_name,i," ");
	end;
	drop i _name;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 02 Feb 2020 18:54:30 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-02-02T18:54:30Z</dc:date>
    <item>
      <title>How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621796#M19652</link>
      <description>&lt;P&gt;DineshReddy&lt;BR /&gt;RajeshRaoReddy&lt;BR /&gt;PraveenKumarRaoKumar&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ans needed as&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Var1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Var2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Var3&amp;nbsp; &amp;nbsp; &amp;nbsp; Var4&lt;BR /&gt;1. Dinesh&amp;nbsp; &amp;nbsp;Reddy&lt;BR /&gt;2. Rajesh&amp;nbsp; &amp;nbsp;Rao&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Reddy&lt;BR /&gt;3. Praveen Kumar&amp;nbsp; &amp;nbsp; Rao&amp;nbsp; &amp;nbsp; &amp;nbsp; Kumar&lt;/P&gt;&lt;P&gt;total we need 4 variables&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 18:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621796#M19652</guid>
      <dc:creator>Rakesh93</dc:creator>
      <dc:date>2020-02-02T18:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621798#M19653</link>
      <description>&lt;P&gt;Maybe it helps:&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Split-the-string-into-two-parts/td-p/133091" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Split-the-string-into-two-parts/td-p/133091&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 18:37:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621798#M19653</guid>
      <dc:creator>MargoBlue</dc:creator>
      <dc:date>2020-02-02T18:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621799#M19654</link>
      <description>&lt;P&gt;Something like this? Your delimiter is an UPPER case letter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input name :$50.;
	datalines;
DineshReddy
RajeshRaoReddy
PraveenKumarRaoKumar
;
run;

data want;
	set have;
	array names {4} $ var1-var4;

	do _i=1 to dim(names);
		_this_upper=anyupper(name, _this_upper+1);
		_next_upper=anyupper(name, _this_upper+1);

		if _next_upper=0 then
			_next_upper=length(name)+1;

		if _this_upper&amp;gt;0 then names[_i]=substr(name, _this_upper, _next_upper-_this_upper);
		else
			leave;
	end;
	drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 18:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621799#M19654</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2020-02-02T18:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621800#M19655</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294186"&gt;@Rakesh93&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is a way to achieve this, using pearl regular expressions.&lt;/P&gt;
&lt;P&gt;NB: the proc sql step enables you not to specify arbitrary 4 as the maximum count of words.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input name $80.;
	datalines;
DineshReddy
RajeshRaoReddy
PraveenKumarRaoKumar
;
run;

data have1;
	set have;
	_name= prxchange('s/([A-Z])/ $1/',-1,name);
run;

proc sql noprint;
	select max(countw(_name)) into:nb_max from have1;
quit;

data want;
	set have1;
	array var(&amp;amp;nb_max) $20.;
	do i=1 to countw(_name);
		var(i)=scan(_name,i," ");
	end;
	drop i _name;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 18:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621800#M19655</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-02T18:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621803#M19656</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
	input name :$50.;
	datalines;
DineshReddy
RajeshRaoReddy
PraveenKumarRaoKumar
;
run;

data want;
 set have;
 array names {4} $ var1-var4;
 do _pos=anyupper(name)by 0 while(_pos);
  _p=_pos;
  _pos=anyupper(name,_pos+1);
  _n=sum(_n,1);
  if _pos then  names(_n)=substr(name,_p,_pos-_p);
  else names(_n)=substr(name,_p);
 end;
 drop _:;
run;
proc print noobs;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;name&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var2&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var3&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var4&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;DineshReddy&lt;/TD&gt;
&lt;TD class="l data"&gt;Dinesh&lt;/TD&gt;
&lt;TD class="l data"&gt;Reddy&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;RajeshRaoReddy&lt;/TD&gt;
&lt;TD class="l data"&gt;Rajesh&lt;/TD&gt;
&lt;TD class="l data"&gt;Rao&lt;/TD&gt;
&lt;TD class="l data"&gt;Reddy&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;PraveenKumarRaoKumar&lt;/TD&gt;
&lt;TD class="l data"&gt;Praveen&lt;/TD&gt;
&lt;TD class="l data"&gt;Kumar&lt;/TD&gt;
&lt;TD class="l data"&gt;Rao&lt;/TD&gt;
&lt;TD class="l data"&gt;Kumar&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sun, 02 Feb 2020 19:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621803#M19656</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-02T19:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621804#M19657</link>
      <description>&lt;P&gt;And a variant of the previous with COMPRESS and FINDC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
 array names {4} $ var1-var4;
  _t=strip(compress(name,,'kU'));
 do _pos=findc(compress(name),_t)by 0 while(_pos);
  _p=_pos;
  _pos=findc(compress(name),_t,_pos+1);
  _n=sum(_n,1);
  if _pos then  names(_n)=substr(name,_p,_pos-_p);
  else names(_n)=substr(name,_p);
 end;
 drop _:;
run;
proc print noobs;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;name&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var2&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var3&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var4&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;DineshReddy&lt;/TD&gt;
&lt;TD class="l data"&gt;Dinesh&lt;/TD&gt;
&lt;TD class="l data"&gt;Reddy&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;RajeshRaoReddy&lt;/TD&gt;
&lt;TD class="l data"&gt;Rajesh&lt;/TD&gt;
&lt;TD class="l data"&gt;Rao&lt;/TD&gt;
&lt;TD class="l data"&gt;Reddy&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;PraveenKumarRaoKumar&lt;/TD&gt;
&lt;TD class="l data"&gt;Praveen&lt;/TD&gt;
&lt;TD class="l data"&gt;Kumar&lt;/TD&gt;
&lt;TD class="l data"&gt;Rao&lt;/TD&gt;
&lt;TD class="l data"&gt;Kumar&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sun, 02 Feb 2020 19:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621804#M19657</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-02T19:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621805#M19658</link>
      <description>Can you please explain how does this code works??&lt;BR /&gt;</description>
      <pubDate>Sun, 02 Feb 2020 20:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621805#M19658</guid>
      <dc:creator>Rakesh93</dc:creator>
      <dc:date>2020-02-02T20:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621807#M19659</link>
      <description>&lt;P&gt;Here's a commented version -- tried to describe as best as possible..:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	array names {4} $ var1-var4; *Create an array var1-var4;

	do _i=1 to dim(names); *Work across arrays i=1 to 4 in this case;
		*Use anyupper function to get positions of uppercase characters;
		*First parameter is string to search, second parameter is starting position to search;
		*-- returns 0 if there are no more uppercase characters after specified starting position.;
		_this_upper=anyupper(name, _this_upper+1); *position (index) of THIS upper character;
		_next_upper=anyupper(name, _this_upper+1); *position (index) of NEXT upper character;

		if _next_upper=0 then 
			_next_upper=length(name)+1; *If next upper is 0 (i.e. no more uppercase characters, then change to ending index +1 (helps to get very last chunk out properly);

		if _this_upper&amp;gt;0 then names[_i]=substr(name, _this_upper, _next_upper-_this_upper); *If this upper index is &amp;gt; 0 then capture the substr between this upper and the next one;
		else
			leave; *Else leave and move to next observation (i.e. go from row 1 to row 2);
	end;
	drop _:; *I've named all of my helper variables starting with '_', this drops all of them.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Feb 2020 20:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621807#M19659</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2020-02-02T20:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621810#M19660</link>
      <description>Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 02 Feb 2020 21:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621810#M19660</guid>
      <dc:creator>Rakesh93</dc:creator>
      <dc:date>2020-02-02T21:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621858#M19670</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294186"&gt;@Rakesh93&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code loops through the original NAME letter by letter, appending the individual letter to the "current" name component.&amp;nbsp; Every time the loop encounters an uppercase letter, it just increments which word is considered current:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input name :$30.;
datalines;
DineshReddy
RajeshRaoReddy
PraveenKumarRaoKumar
;

data want (drop=L w);
  set have;
  array n {4} $10 name1-name4;
  do L=1 to length(name);
    if char(name,L) = upcase(char(name,L)) then w=sum(w,1);
    n{w}=cats(n{w},char(name,L));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2020 05:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/621858#M19670</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-02-03T05:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/622119#M19715</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input name :$30.;
datalines;
DineshReddy
RajeshRaoReddy
PraveenKumarRaoKumar
;
data temp;
set have;
id+1;
pid=prxparse('/[A-Z][a-z]+/');
s=1;e=length(name);
call prxnext(pid,s,e,name,p,l);
do while(p&amp;gt;0);
 var=substr(name,p,l);
 output;
call prxnext(pid,s,e,name,p,l);
end;
keep id var;
run;
proc transpose data=temp out=want prefix=var_;
by id;
var var;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Feb 2020 06:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/622119#M19715</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-02-04T06:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a name string with no delimiters into columns/variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/622130#M19717</link>
      <description>&lt;P&gt;This works&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input names:$50.;
cards;
DineshReddy
RajeshRaoReddy
PraveenKumarRaoKumar
;
run;


data temp(drop=i);
set have;
 do i=1 to length(names)+1;
 	if (rank(substr(names,i,1)) gt 64 and rank(substr(names,i,1)) lt 91 and i ne 1) or i=length(names)+1 then do;
 		output;
 		name=substr(names,i,1);
 	end;
 	else name=cats(name,substr(names,i,1));
 end;
run;

proc sort data=temp;
by names;
run;

proc transpose data=temp out=want(drop=_name_);
by names;
var name;
run;&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>Tue, 04 Feb 2020 07:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Split-a-name-string-with-no-delimiters-into-columns/m-p/622130#M19717</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2020-02-04T07:26:30Z</dc:date>
    </item>
  </channel>
</rss>

