<?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: Extract first letters from each variable left to right  and  right to left in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926860#M364770</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390518"&gt;@pavank&lt;/a&gt;&amp;nbsp;Nothing wrong with your code but there are of course almost always a multitude of coding options. Here one more:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    length left_to_right right_to_left $5;
    keep left_to_right right_to_left;
    left_to_right=catx(' ',first(name),first(gender),first(city));
    right_to_left=reverse(left_to_right);;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 May 2024 02:27:44 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-05-03T02:27:44Z</dc:date>
    <item>
      <title>Extract first letters from each variable left to right  and  right to left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926767#M364714</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input Name $ Gender $ City $12.;
    datalines;
Srilakshmi Female Hyderabad
Vamika Female Bangalore
Prajwal Male Mumbai
;
run;

data want;
    set have;
    City = substr(City, 1, 1);
    Gender = substr(Gender, 1, 1);
    Name = substr(scan(Name, 1), 1, 1);
    drop Name Gender City;
    left_to_right=catx(' ',name,gender,city);
    right_to_left=catx(' ',city,gender,name);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi Guys ,&lt;/P&gt;
&lt;P&gt;Here i want to extract first letter from each variable left to right and right to left&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is it correct way or any other method to achieve could you please give solution&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 11:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926767#M364714</guid>
      <dc:creator>pavank</dc:creator>
      <dc:date>2024-05-02T11:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extract first letters from each variable left to right  and  right to left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926769#M364716</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390518"&gt;@pavank&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here i want to extract first letter from each variable left to right and right to left&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is it correct way or any other method to achieve could you please give solution&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You don't have to ask us "is it correct". You run the code and see if it is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a relatively short piece of code and if it does what you want, then I wouldn't bother searching for another solution (unless your question is purely to learn alternatives)&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 11:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926769#M364716</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-05-02T11:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Extract first letters from each variable left to right  and  right to left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926770#M364717</link>
      <description>&lt;P&gt;It looks like your program drops the original variabes.&amp;nbsp; Nothing wrong with that, but if you don't need them this simplification comes to mind:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   length city gender name $ 1;
    set have;
    drop Name Gender City;
    left_to_right=catx(' ',name,gender,city);
    right_to_left=catx(' ',city,gender,name);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just shorten the variables, and forget about SUBSTR.&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 11:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926770#M364717</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-05-02T11:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Extract first letters from each variable left to right  and  right to left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926778#M364723</link>
      <description>&lt;P&gt;Check or the FIRST function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1af3wnk52qg49n1xcdk1wpcmucy.htm" target="_self"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1af3wnk52qg49n1xcdk1wpcmucy.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 13:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926778#M364723</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-05-02T13:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extract first letters from each variable left to right  and  right to left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926860#M364770</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390518"&gt;@pavank&lt;/a&gt;&amp;nbsp;Nothing wrong with your code but there are of course almost always a multitude of coding options. Here one more:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    length left_to_right right_to_left $5;
    keep left_to_right right_to_left;
    left_to_right=catx(' ',first(name),first(gender),first(city));
    right_to_left=reverse(left_to_right);;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 02:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-first-letters-from-each-variable-left-to-right-and-right/m-p/926860#M364770</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-05-03T02:27:44Z</dc:date>
    </item>
  </channel>
</rss>

