<?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: Why '&amp;amp;loc1'n doesn't replace &amp;quot; &amp;quot; with a &amp;quot;_&amp;quot; in SAS studio university edi in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Why-amp-loc1-n-doesn-t-replace-quot-quot-with-a-quot-quot-in-SAS/m-p/596321#M8141</link>
    <description>&lt;P&gt;You will need to show more details. It is not clear if the variables are named with spaces or underscores and what you want them to changed to. It is not clear what the macro variables contain.&amp;nbsp; Also why are you changing the names to SITE1, SITE2 etc?&amp;nbsp; At first it sounded like you just wanted to change&amp;nbsp;&lt;SPAN&gt;"Derry Medical Center"n to Derry_Medical_Center, not give a generic name like SITE1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember that macro expressions are not evaluated inside of single quotes. So&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'&amp;amp;macro'n&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is looking for a variable named literally &amp;amp;macro instead of one whose name is contained in the value the macro variable named MACRO. Use the double quote character instead of the single quote character.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"&amp;amp;macro"n&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Oct 2019 16:24:02 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-10-14T16:24:02Z</dc:date>
    <item>
      <title>Why '&amp;loc1'n doesn't replace " " with a "_" in SAS studio university edition?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Why-amp-loc1-n-doesn-t-replace-quot-quot-with-a-quot-quot-in-SAS/m-p/596315#M8140</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a file which is already in sas7bdat form, and there is a variable with observation written in a usual way, for example I have "Derry Medical Center" instead of "Derry_Medical_Center". I need to do analysis for each of distinct observations so I use proc sql to save those distinct values as macro-variables "loc1", "loc2", ..., "loc10".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After some data processing processes, those distinct values become the variable names for another dataset and it is automatically transferred to "&lt;SPAN&gt;Derry_Medical_Center" by SAS. Now I want to rename those variable names as "site1", "site2", ..., "site10". So I used the code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;rename=("&amp;amp;loc1"n=site1 "&amp;amp;loc2"n=site2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The code works in SAS but&lt;/SPAN&gt;&amp;nbsp;is not working in my SAS Studio (University Edition). '&amp;amp;macro'n does not replace the blank with an underscore. Can&lt;SPAN&gt;&amp;nbsp;someone please explain to me why and how to solve this issue?&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 16:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Why-amp-loc1-n-doesn-t-replace-quot-quot-with-a-quot-quot-in-SAS/m-p/596315#M8140</guid>
      <dc:creator>Wendy_J</dc:creator>
      <dc:date>2019-10-14T16:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why '&amp;loc1'n doesn't replace " " with a "_" in SAS studio university edi</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Why-amp-loc1-n-doesn-t-replace-quot-quot-with-a-quot-quot-in-SAS/m-p/596321#M8141</link>
      <description>&lt;P&gt;You will need to show more details. It is not clear if the variables are named with spaces or underscores and what you want them to changed to. It is not clear what the macro variables contain.&amp;nbsp; Also why are you changing the names to SITE1, SITE2 etc?&amp;nbsp; At first it sounded like you just wanted to change&amp;nbsp;&lt;SPAN&gt;"Derry Medical Center"n to Derry_Medical_Center, not give a generic name like SITE1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember that macro expressions are not evaluated inside of single quotes. So&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'&amp;amp;macro'n&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is looking for a variable named literally &amp;amp;macro instead of one whose name is contained in the value the macro variable named MACRO. Use the double quote character instead of the single quote character.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"&amp;amp;macro"n&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 16:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Why-amp-loc1-n-doesn-t-replace-quot-quot-with-a-quot-quot-in-SAS/m-p/596321#M8141</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-14T16:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Why '&amp;loc1'n doesn't replace " " with a "_" in SAS studio university edi</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Why-amp-loc1-n-doesn-t-replace-quot-quot-with-a-quot-quot-in-SAS/m-p/596324#M8142</link>
      <description>&lt;P&gt;OK. Here is the list of original names:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Derry Medical Center&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Princeton - Plainsboro&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;St. Eligus Hospital&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Twin Pines Medical Center&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And SAS automatically changed it to the following after I transposed the data so that those become the variable names:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Derry_Medical_Center&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Princeton___Plainsboro&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;St__Eligus_Hospital&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Twin_Pines_Medical_Center&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to rename those variables to site1, site2, site3, and site4. I used "&amp;amp;maco"n in SAS studio and that works but after I changed to the university edition it doesn't work anymore.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW, I have already used the double quote in my code:&lt;/P&gt;&lt;P&gt;rename=("&amp;amp;loc1"n=site1 "&amp;amp;loc2"n=site2 "&amp;amp;loc3"n=site3 "&amp;amp;loc4"n=site4)&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 16:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Why-amp-loc1-n-doesn-t-replace-quot-quot-with-a-quot-quot-in-SAS/m-p/596324#M8142</guid>
      <dc:creator>Wendy_J</dc:creator>
      <dc:date>2019-10-14T16:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why '&amp;loc1'n doesn't replace " " with a "_" in SAS studio university edi</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Why-amp-loc1-n-doesn-t-replace-quot-quot-with-a-quot-quot-in-SAS/m-p/596327#M8143</link>
      <description>&lt;P&gt;So you want to get a list of variable names and rename them to SITE1 to SITEn.&lt;/P&gt;
&lt;P&gt;Just get the list of variable names, using PROC CONTENTS or other methods.&lt;/P&gt;
&lt;P&gt;Then number them (or perhaps use the VARNUM variable that metadata like PROC CONTENTS output will already have.&lt;/P&gt;
&lt;P&gt;Then use the name and the number to generate to rename string.&amp;nbsp; Use the NLITERAL() function and it won't matter if the names are normal SAS names or ones that include spaces and other invalid characters for names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select catx('=',nliteral(name),cats('site',varnum))
  into :rename_list
  from my_variable_list
;
quit;

proc datasets lib=mylib ;
  modify my_dataset;
    rename &amp;amp;rename_list;
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might also explain what process you are doing that is changing the names. Perhaps you can avoid the need for name changes if you change that step instead.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 16:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Why-amp-loc1-n-doesn-t-replace-quot-quot-with-a-quot-quot-in-SAS/m-p/596327#M8143</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-14T16:51:39Z</dc:date>
    </item>
  </channel>
</rss>

