<?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 Extract values for two related variables in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Extract-values-for-two-related-variables/m-p/384463#M3182</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three variables, drug_ID, drug_name, and strength. Here is an example of the data format for these three variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;drug_ID &amp;nbsp; drug_name &amp;nbsp; &amp;nbsp;strength&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A/B/C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 mg-10 mg-5 mg&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10 mg&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;E/F &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7 mg-15mg&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;E/B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 13 mg-8 mg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where A, B, ... are active ingredients of a drug. As you can see, for each observation, each active ingredient has a specific strength (in dosage). Also, note that A, B, ... are just examples. In the data, each ingredient may have different strings, e,.g., A = acetaminophen, B = codeine, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, my question is that how can I return the strength for each active ingredient for each drug_ID? For example, for drug 1, I need to return 5, 10, and 5 mg for A, B, and C, respectively. Any help/idea is appreciated!&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2017 22:57:44 GMT</pubDate>
    <dc:creator>Alireza_Boloori</dc:creator>
    <dc:date>2017-07-31T22:57:44Z</dc:date>
    <item>
      <title>Extract values for two related variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Extract-values-for-two-related-variables/m-p/384463#M3182</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three variables, drug_ID, drug_name, and strength. Here is an example of the data format for these three variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;drug_ID &amp;nbsp; drug_name &amp;nbsp; &amp;nbsp;strength&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A/B/C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 mg-10 mg-5 mg&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10 mg&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;E/F &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7 mg-15mg&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;E/B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 13 mg-8 mg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where A, B, ... are active ingredients of a drug. As you can see, for each observation, each active ingredient has a specific strength (in dosage). Also, note that A, B, ... are just examples. In the data, each ingredient may have different strings, e,.g., A = acetaminophen, B = codeine, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, my question is that how can I return the strength for each active ingredient for each drug_ID? For example, for drug 1, I need to return 5, 10, and 5 mg for A, B, and C, respectively. Any help/idea is appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 22:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Extract-values-for-two-related-variables/m-p/384463#M3182</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2017-07-31T22:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract values for two related variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Extract-values-for-two-related-variables/m-p/384474#M3183</link>
      <description>&lt;P&gt;You can use SCAN function on both variables.&lt;/P&gt;
&lt;P&gt;Please post how do you want to format your output ?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 00:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Extract-values-for-two-related-variables/m-p/384474#M3183</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-01T00:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extract values for two related variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Extract-values-for-two-related-variables/m-p/384480#M3184</link>
      <description>Thanks! I used a combination of SCAN and INDEX to find my solution.</description>
      <pubDate>Tue, 01 Aug 2017 01:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Extract-values-for-two-related-variables/m-p/384480#M3184</guid>
      <dc:creator>Alireza_Boloori</dc:creator>
      <dc:date>2017-08-01T01:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extract values for two related variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Extract-values-for-two-related-variables/m-p/384481#M3185</link>
      <description>&lt;P&gt;you could try something as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input drug_ID$   drug_name$ 16- 22  strength$ 34-49;
cards;
1              A/B/C             5 mg-10 mg-5 mg
2              D                   10 mg
3              E/F                7 mg-15mg
4              E/B               13 mg-8 mg
;


data want;
set have;
do i=1 to countw(drug_name,'/');
drug=scan(drug_name,i,'/');
dose=scan(strength,i,'-');
output;
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Aug 2017 01:37:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Extract-values-for-two-related-variables/m-p/384481#M3185</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-08-01T01:37:02Z</dc:date>
    </item>
  </channel>
</rss>

