<?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 split name as single letter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878153#M346946</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data newdata (keep=word1-word7 name seqno);
retain seqno name;
array myvar (*)$ word1-word7;
set sashelp.class ;
by name notsorted;

	do seqno=1 to 7;
		do i= 1 to 7;
myvar(i)=substr(Name,i,1);
if last.name then output;

output; 
end;
end;
proc print noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;how to get&amp;nbsp; complete split letters names&amp;nbsp; output like below&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 432pt;" border="0" width="576" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl63" style="height: 15.0pt; width: 48pt;"&gt;seqno&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;name&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word1&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word2&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word3&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word4&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word5&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word6&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;1&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;Alfred&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;l&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;f&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;r&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;e&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;d&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;Alice&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;l&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;i&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;c&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;e&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;Barbara&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;B&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;a&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;r&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;b&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;a&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;r&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;a&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
    <pubDate>Tue, 30 May 2023 04:54:05 GMT</pubDate>
    <dc:creator>BrahmanandaRao</dc:creator>
    <dc:date>2023-05-30T04:54:05Z</dc:date>
    <item>
      <title>split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878153#M346946</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data newdata (keep=word1-word7 name seqno);
retain seqno name;
array myvar (*)$ word1-word7;
set sashelp.class ;
by name notsorted;

	do seqno=1 to 7;
		do i= 1 to 7;
myvar(i)=substr(Name,i,1);
if last.name then output;

output; 
end;
end;
proc print noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;how to get&amp;nbsp; complete split letters names&amp;nbsp; output like below&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 432pt;" border="0" width="576" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl63" style="height: 15.0pt; width: 48pt;"&gt;seqno&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;name&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word1&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word2&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word3&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word4&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word5&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word6&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;word7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;1&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;Alfred&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;l&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;f&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;r&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;e&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;d&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;Alice&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;l&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;i&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;c&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;e&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;Barbara&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;B&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;a&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;r&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;b&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;a&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;r&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;a&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 30 May 2023 04:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878153#M346946</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-30T04:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878154#M346947</link>
      <description>&lt;P&gt;Why&amp;nbsp; do you have two OUTPUT statements? Why do you use BY when there is only one observation per name anyway?&lt;/P&gt;
&lt;P&gt;To create a sequential count variable, use RETAIN and a sum statement, you do not need a DO loop for this.&lt;/P&gt;
&lt;P&gt;And use proper indentation when writing code, as all the people here are constantly showing you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hints: do not use an explicit OUTPUT, the DATA step will do this for you. Use one DO loop to scan through the name.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 05:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878154#M346947</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-30T05:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878161#M346949</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data newdata (keep=Letter_1-Letter_7 name);
	retain  name;
	array myvar (*)$ Letter_1-Letter_7;
	set sashelp.class;

	do i=1 to dim(myvar);
		myvar(i)=upcase(substr(name, i, 1));
	end;

proc print noobs;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Anandkvn_0-1685425376763.png" style="width: 320px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84457i34B66F870A1AFBC2/image-dimensions/320x294?v=v2" width="320" height="294" role="button" title="Anandkvn_0-1685425376763.png" alt="Anandkvn_0-1685425376763.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 05:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878161#M346949</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-30T05:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878162#M346950</link>
      <description>&lt;P&gt;Study the documentation of the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0t2ac0tfzcgbjn112mu96hkgg9o.htm" target="_blank" rel="noopener"&gt;RETAIN Statement&lt;/A&gt;, and then decide if it is needed here, or if it does not serve any purpose at all.&lt;/P&gt;
&lt;P&gt;Also look at the length of your newly created variables, you may want to change that, as you only store one character each.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 05:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878162#M346950</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-30T05:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878163#M346951</link>
      <description>&lt;P&gt;if I were you I would take a bit different approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  set sashelp.class(keep=name) end=E;
  output;
  if E then
  do;
    name='空手道';
    output;
    name='Żółć';
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=want;
by name;
run;

data want;
  set want;
  by name;
  do i=1 to KLENGTH(name);
    word = KSUBSTR(name,i,1);
    output;
  end;
run;
proc print;run;

proc transpose data=want out=want(drop=_name_) prefix=word;
  by name;
  var word;
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Comments:&lt;/P&gt;
&lt;P&gt;- Use klength() and ksubstr() to properly handle &lt;U&gt;multi byte characters&lt;/U&gt; (which are quite common in names).&lt;/P&gt;
&lt;P&gt;- Use data step to cut letters one by one and then use Proc Transpose, with that approach you won't have to assume maximum length of a name imagine you will have "Broomhilda" or "Małgorzata", or &lt;A href="https://en.wikipedia.org/wiki/Hubert_Blaine_Wolfeschlegelsteinhausenbergerdorff_Sr." target="_self"&gt;this&lt;/A&gt; man, which are much longer than 7 letters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 06:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878163#M346951</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-30T06:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878202#M346960</link>
      <description>&lt;P&gt;Something like below should do.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select length into :len trimmed
  from dictionary.columns
  where libname='SASHELP' and memname='CLASS' and upcase(name)="NAME"
  ;
quit;

data newdata (keep=name letter_:);
  set sashelp.class;
  array letter_ (&amp;amp;len) $1;
  do _i=1 to length(name);
    letter_[_i]=substr(name,_i,1);
  end;
run;

proc print data=newdata noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2023 12:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878202#M346960</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-05-30T12:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878358#M347022</link>
      <description>&lt;P&gt;Thank you Patrick for you solution how can get only maximum length names in the above class dataset&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 07:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878358#M347022</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-31T07:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878364#M347023</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you Patrick for you solution how can get only maximum length names in the above class dataset&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please explain in more detail.&lt;/P&gt;
&lt;P&gt;Do you want to display the maximun encountered length of a name at the end of the step, or do you want to only process the names having this maximum length, or even subset the dataset to these names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See Maxim 42.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 07:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878364#M347023</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-31T07:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878365#M347024</link>
      <description>&lt;P&gt;Hi kurt&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want get which name has maximum length those names only displays&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 07:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878365#M347024</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-31T07:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878367#M347025</link>
      <description>&lt;P&gt;In a first step, determine the maximum length (e.g. with PROC SQL SELECT INTO), then use this value in a WHERE.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 07:53:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878367#M347025</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-31T07:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878370#M347027</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
  select max(length(Name)) as maxlen into :len separated by ' '
  from newdata
  
  having name=max(name);
  
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 May 2023 08:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878370#M347027</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-31T08:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878371#M347028</link>
      <description>&lt;P&gt;MAX of a character value gets the&amp;nbsp;&lt;EM&gt;lexically&lt;/EM&gt; "highest" (e.g. "Z" is higher than "A"), so I ask what you want to achieve with your HAVING clause?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 08:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878371#M347028</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-31T08:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878380#M347035</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data newdata (keep=Letter_1-Letter_7 name sex);
	retain  name;
	array myvar (*)$ Letter_1-Letter_7;
	set sashelp.class;

	do i=1 to dim(myvar);
		myvar(i)=upcase(substr(name, i, 1));
	end;

proc print noobs;
run;

/*Maximum length string in the newdataset */

PROC SQL;
   SELECT Name ,letter_1,letter_2,letter_3,letter_4,letter_5,letter_6,letter_7
   FROM NEWDATA
   WHERE LENGTH(Name) = (SELECT MAX(LENGTH(Name)) FROM NEWDATA);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 May 2023 09:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878380#M347035</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-31T09:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878383#M347037</link>
      <description>&lt;P&gt;Please READ my posts, and read them THOROUGHLY. I said you have to determine the maximum length in a&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;FIRST&lt;/STRONG&gt;&lt;/U&gt; step, so you can then use it in the WHERE condition of the DATA step that splits the name.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 09:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878383#M347037</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-31T09:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878392#M347042</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* maximum length names output using datastep*/

data newdata (keep=Letter_1-Letter_7 name sex  );
	retain  name;
	array myvar (*)$ Letter_1-Letter_7;
	set sashelp.class;
    
	do i=1 to dim(myvar);
		myvar(i)=upcase(substr(name, i, 1));
		where max(length(name))=7  ;
	end;

proc print noobs;
run;
/*max and min names length using proc sql*/
PROC SQL;
   SELECT name,sex,letter_1,letter_2,letter_3,letter_4,letter_5,letter_6,letter_7,MAX(LENGTH(Name)) AS MaxLengthFemale
   FROM newdata
   WHERE Sex = 'F';
   
   SELECT name,sex,letter_1,letter_2,letter_3,letter_4,letter_5,letter_6,letter_7,MIN(LENGTH(Name)) AS MinLengthMale
   FROM newdata
   WHERE Sex = 'M';
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;1.How to get min and max names length output in datastep&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 10:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878392#M347042</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-31T10:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878398#M347044</link>
      <description>&lt;P&gt;Jumping in late here, and I realize this is a made up problem, but I cannot imagine what a "real" problem would be that requires these techniques. Could you please&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;tell us what the "real" problem is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have spent a lot of time without a solution so far, and the translation to the "real" problem, whatever it is, may not be trivial. In addition, this strikes me as another example of the &lt;A href="https://en.wikipedia.org/wiki/XY_problem" target="_self"&gt;XY Problem&lt;/A&gt;, and knowing what the "real" problem is would point us in the right direction. In addition, any method that takes a long data set and turns it into a wide data set is a red-flag to me (while there are a few situations where that is necessary, most of the time it is a poor approach that takes you in the wrong direction, and misses easier ways to handle the data).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to sum up, I think we have spent a lot of time on this, and that time would be better spent working on the "real" problem, not this made-up problem.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 12:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878398#M347044</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-31T12:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878427#M347055</link>
      <description>Use RETAINed variables (for max, start with 0, for min, start with 32767), use the MAX and MIN functions, and OUTPUT at the end (use the END= option in the SET statement).&lt;BR /&gt;Quite a simple problem, you can easily solve this on your own after 650+ posts here.</description>
      <pubDate>Wed, 31 May 2023 14:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878427#M347055</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-31T14:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878501#M347088</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;
&lt;P&gt;I am not getting solution in datastep&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 17:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878501#M347088</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-31T17:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: split name as single letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878530#M347101</link>
      <description>&lt;P&gt;You obviously didn't even give it a try, or you would have posted your code and log.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 18:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-name-as-single-letter/m-p/878530#M347101</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-31T18:47:20Z</dc:date>
    </item>
  </channel>
</rss>

