<?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 extract information from a variable and create a new variable with it? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-information-from-a-variable-and-create-a-new/m-p/427641#M105519</link>
    <description>Thank you so much!!!!!!!!!!</description>
    <pubDate>Mon, 15 Jan 2018 10:14:57 GMT</pubDate>
    <dc:creator>marysmith</dc:creator>
    <dc:date>2018-01-15T10:14:57Z</dc:date>
    <item>
      <title>How to extract an information from a variable and create a new variabl with it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-information-from-a-variable-and-create-a-new/m-p/426530#M105096</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got a pretty advanced task and I have absolutely no idea how to do this. So feel free to help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have a variable "medicinalproduct", which contains a lot of different informations. One information is the API Code (as you can see in the picture). The Code itself has always the same sequence. It always starts with a letter, then its 2 numbers, 2 letters, 2 numbers(for example in the first line, the API Code is &lt;STRONG&gt;B03XA01&lt;/STRONG&gt;. I need to extract this code from the variable and have to create a new variable called API.&lt;/P&gt;&lt;P&gt;How can I do this? I have absolutely no idea. Does anybody know?Thank you soo much for your help. Cheers, Mary.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="The Variable I need to extract the API Code from" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17766iDBFF4D95EFAC8C74/image-size/large?v=v2&amp;amp;px=999" role="button" title="meds.PNG" alt="The Variable I need to extract the API Code from" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;The Variable I need to extract the API Code from&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="proc_contents.JPG" style="width: 491px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17767iD19504F105D7FD87/image-size/large?v=v2&amp;amp;px=999" role="button" title="proc_contents.JPG" alt="proc_contents.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 16:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-information-from-a-variable-and-create-a-new/m-p/426530#M105096</guid>
      <dc:creator>marysmith</dc:creator>
      <dc:date>2018-01-10T16:25:52Z</dc:date>
    </item>
    <item>
      <title>How to extract information from a variable and create a new variable with it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-information-from-a-variable-and-create-a-new/m-p/426536#M105100</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got a pretty advanced task and I have absolutely no idea how to do this. So feel free to help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have a variable "medicinalproduct", which contains a lot of different informations. One information is the API Code (as you can see in the picture). The Code itself has always the same sequence. It always starts with a letter, then its 2 numbers, 2 letters, 2 numbers(for example in the first line, the API Code is &lt;STRONG&gt;B03XA01&lt;/STRONG&gt;. I need to extract this code from the variable and have to create a new variable called API.&lt;/P&gt;&lt;P&gt;How can I do this? I have absolutely no idea. Does anybody know?Thank you soo much for your help.&lt;/P&gt;&lt;P&gt;Cheers, Mary.&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="meds.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17769i3A61D471C41FDBBE/image-size/large?v=v2&amp;amp;px=999" role="button" title="meds.PNG" alt="meds.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 16:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-information-from-a-variable-and-create-a-new/m-p/426536#M105100</guid>
      <dc:creator>marysmith</dc:creator>
      <dc:date>2018-01-10T16:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract information from a variable and create a new variable with it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-information-from-a-variable-and-create-a-new/m-p/426546#M105106</link>
      <description>&lt;P&gt;Please post data in the form of a data step and not a picture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a fit for PRXMATCH I think.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data textfield;
   input medicinalproduct $100. ;
datalines;
upon a 23234night both dampB03XA01 and dreary GX334&amp;amp;$% when I was so4789 very weary%%$
there came a raven L01XA03 knocking at my door
it was the bV08AB09Rest of time and the worst of ravens
;

data apicodes;
	set textfield;
	startpos = prxmatch('[[A-Z]{1}[0-9]{2}[A-Z]{2}[0-9]{2}]', medicinalproduct);
	apicode = substr(medicinalproduct, startpos, 7);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I can get&lt;/P&gt;
&lt;TABLE width="374"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="256"&gt;The SAS System&lt;/TD&gt;
&lt;TD width="57"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="61"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="256"&gt;medicinalproduct&lt;/TD&gt;
&lt;TD width="57"&gt;startpos&lt;/TD&gt;
&lt;TD width="61"&gt;apicode&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="256"&gt;upon a 23234night both dampB03XA01 and dreary GX334&amp;amp;$% when I was so4789 very weary%%$&lt;/TD&gt;
&lt;TD width="57"&gt;28&lt;/TD&gt;
&lt;TD width="61"&gt;B03XA01&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="256"&gt;there came a raven L01XA03 knocking at my door&lt;/TD&gt;
&lt;TD width="57"&gt;20&lt;/TD&gt;
&lt;TD width="61"&gt;L01XA03&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="256"&gt;it was the bV08AB09Rest of time and the worst of ravens&lt;/TD&gt;
&lt;TD width="57"&gt;13&lt;/TD&gt;
&lt;TD width="61"&gt;V08AB09&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps that is helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am terrible at regex development so somebody else here can probably make you a much terser expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 17:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-information-from-a-variable-and-create-a-new/m-p/426546#M105106</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2018-01-10T17:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract information from a variable and create a new variable with it?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-information-from-a-variable-and-create-a-new/m-p/427641#M105519</link>
      <description>Thank you so much!!!!!!!!!!</description>
      <pubDate>Mon, 15 Jan 2018 10:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-information-from-a-variable-and-create-a-new/m-p/427641#M105519</guid>
      <dc:creator>marysmith</dc:creator>
      <dc:date>2018-01-15T10:14:57Z</dc:date>
    </item>
  </channel>
</rss>

