<?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: Replacing two sections of a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-two-sections-of-a-string/m-p/287451#M59149</link>
    <description>&lt;P&gt;You can try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cntlin;
set cont;
rename
  names=start
  labels=label
;
fmtname = 'labelformat';
type = 'C';
run;

proc format libary=work cntlin=cntlin;
run;

data want;
set have;
new_effect = ' ';
do i = 1 to countw(effect,'*');
  new_effect = catx('*',trim(new_effect),put(scan(effect,i,'*'),$labelformat.));
end;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Jul 2016 12:12:27 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-07-27T12:12:27Z</dc:date>
    <item>
      <title>Replacing two sections of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-two-sections-of-a-string/m-p/287448#M59146</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running several models. My independent variables are called V1, V2, V3, etc...The output of the models (glmselect) returns the parameter estimates and P-Values. The effects in the output table can looks like this: V3 in case of a main effect, or like this: V4*V6, in case of an interaction.&lt;/P&gt;&lt;P&gt;In addition, I have a dataset called "cont" with two columns, one is "Names" the variables names (V1, V2, V3,...) and one is "Labels" with the labels.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal (and problem) is to replace the effect text (V2, V2*V3, etc...) with a one based on the labels. I want to do the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the effect is a main effect, I want a new variable to get the label of the main effect from the "cont" dataset. If the effect is an interaction, I need somehow to get the first variable name before the'*', then get the second one after the '*', replace them both with the labels, and put them back together with an '*' between them, and to put all that in the same variable as the label of the main effects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, if my model gave 3 lines (apart from intercept): V1, V2 and V1*V2, I want to replace the first column with a new one that will get the values: Age, Gender, Age*Gender. The values are the labels from "cont".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One last thing to remember, that I will always have an intecept in the table. The label is not on the "cont" dataset and should remain "intercept".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please assist me on how to do this ? Tank you very much in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clarrification: The interactions are only up to 2 variables, nothing like this: V1*V2*V3 is possible.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 11:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-two-sections-of-a-string/m-p/287448#M59146</guid>
      <dc:creator>BlueNose</dc:creator>
      <dc:date>2016-07-27T11:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing two sections of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-two-sections-of-a-string/m-p/287451#M59149</link>
      <description>&lt;P&gt;You can try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cntlin;
set cont;
rename
  names=start
  labels=label
;
fmtname = 'labelformat';
type = 'C';
run;

proc format libary=work cntlin=cntlin;
run;

data want;
set have;
new_effect = ' ';
do i = 1 to countw(effect,'*');
  new_effect = catx('*',trim(new_effect),put(scan(effect,i,'*'),$labelformat.));
end;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jul 2016 12:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-two-sections-of-a-string/m-p/287451#M59149</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-27T12:12:27Z</dc:date>
    </item>
  </channel>
</rss>

