<?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 Displaying a letter from the variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286803#M59522</link>
    <description>&lt;P&gt;Hello here below i have imported a excel sheet which contains certain string&amp;nbsp;i.e&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below is the code i tried can u'll help to correct this code to get my desired output or i use a macro? help! is appreciated....&lt;/P&gt;
&lt;P&gt;thanks...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;set work.temp;&lt;BR /&gt;fullpath=scan(fullpath,-5);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jul 2016 08:49:23 GMT</pubDate>
    <dc:creator>RTelang</dc:creator>
    <dc:date>2016-07-26T08:49:23Z</dc:date>
    <item>
      <title>Displaying a letter from the variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286803#M59522</link>
      <description>&lt;P&gt;Hello here below i have imported a excel sheet which contains certain string&amp;nbsp;i.e&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below is the code i tried can u'll help to correct this code to get my desired output or i use a macro? help! is appreciated....&lt;/P&gt;
&lt;P&gt;thanks...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;set work.temp;&lt;BR /&gt;fullpath=scan(fullpath,-5);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 08:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286803#M59522</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-07-26T08:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying a letter from the particular address</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286808#M59523</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(scan(fullpath,-2,'\'),1,1)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 10:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286808#M59523</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-25T10:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying a letter from the particular address</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286810#M59524</link>
      <description>but how would i incorporate this in a macro?</description>
      <pubDate>Mon, 25 Jul 2016 10:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286810#M59524</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-07-25T10:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying a letter from the particular address</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286815#M59526</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60507"&gt;@RTelang&lt;/a&gt; wrote:&lt;BR /&gt;but how would i incorporate this in a macro?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why would you want to do that?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 10:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286815#M59526</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-25T10:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying a letter from the particular address</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286830#M59528</link>
      <description>I have multiple strings like this in my excel sheet so i would just run the macro &amp;amp; display the letter so i asked abt the macro....</description>
      <pubDate>Mon, 25 Jul 2016 11:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286830#M59528</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-07-25T11:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying a letter from the particular address</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286833#M59530</link>
      <description>&lt;P&gt;This is quite easy, then.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro extract_letter(varname);
&amp;amp;varname = substr(scan(&amp;amp;varname,-2,'\'),1,1);
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You just use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%extract_letter(fullpath);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to get the result from your initial example.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 11:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286833#M59530</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-25T11:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying a letter from the particular address</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286841#M59531</link>
      <description>NOTE: Line generated by the macro variable "VARNAME". &lt;BR /&gt;'D:\Projects\SDTM_Mapping\domains\BD2 - \D - \SDTM-v3.xlsx '&lt;BR /&gt;180&lt;BR /&gt; ERROR 180-322: Statement is not valid or it is used out of proper order. &lt;BR /&gt;this error arises when i run the code with a specific address .&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 12:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286841#M59531</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-07-25T12:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying a letter from the particular address</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286842#M59532</link>
      <description>&lt;P&gt;I guess you still have a severe misunderstanding of the macro language. It is a code generator, not code in itself.&lt;/P&gt;
&lt;P&gt;My macro is supposed to be used on a variable name, not on a string literal!&lt;/P&gt;
&lt;P&gt;That's why the macro parameter is called &lt;U&gt;varname&lt;/U&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 12:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286842#M59532</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-25T12:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying a letter from the particular address</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286850#M59533</link>
      <description>&lt;P&gt;In case you want to use a macro like a function, you need to define it differently. But I'd rather use a user-defined data step function instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro extract_letter(instring);
substr(scan(&amp;amp;instring,-2,'\'),1,1) 
%mend;

proc fcmp outlib=work.funcs.test;
function extract_letter(instring $) $;
  return (substr(scan(instring,-2,'\'),1,1));
endsub;
run;

options cmplib=work.funcs;

data want;
fullpath = 'D:\Projects\SDTM_Mapping\domains\BD2 - \D - \SDTM-v3.xlsx ';
result1 = extract_letter(fullpath);
result2 = extract_letter('D:\Projects\SDTM_Mapping\domains\BD2 - \D - \SDTM-v3.xlsx ');
result3 = %extract_letter(fullpath);
result4 = %extract_letter('D:\Projects\SDTM_Mapping\domains\BD2 - \D - \SDTM-v3.xlsx ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that the results in the dataset from the function will have the desired length of 1, while the results from the macro invocation will default to length 200.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 13:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-a-letter-from-the-variable/m-p/286850#M59533</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-25T13:09:58Z</dc:date>
    </item>
  </channel>
</rss>

