<?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: Old macro ps from RAND in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905397#M357616</link>
    <description>&lt;P&gt;Just set VALIDVARNAME option to V7 before running the PROC IMPORT and you will get a dataset with valid SAS variable names instead of names with periods and other invalid characters in them.&lt;/P&gt;</description>
    <pubDate>Thu, 30 Nov 2023 17:56:57 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-11-30T17:56:57Z</dc:date>
    <item>
      <title>Old macro ps from RAND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905385#M357608</link>
      <description>&lt;P&gt;Old macro &lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#993300"&gt;ps&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt; from RAND corporation is trying to get SAS to play ping-pong with R. The macro is from a family called &lt;FONT color="#993300"&gt;&lt;EM&gt;&lt;STRONG&gt;Twang&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;, named after R package that gets propensity scores, hence the name ps. However, the variable names are illegal for SAS, for example, &lt;FONT color="#993300"&gt;&lt;STRONG&gt;&lt;EM&gt;table.name&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt; is not a good variable name. I cannot even rename it, SAS complains. Workaround? I would like this code to work:&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="comic sans ms,sans-serif" color="#000000"&gt;proc sql noprint;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif" color="#000000"&gt;select distinct &lt;STRONG&gt;&lt;FONT color="#800000"&gt;&lt;EM&gt;table.name&lt;/EM&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif" color="#000000"&gt;into :elements separated by " "&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif" color="#000000"&gt;from _baltab&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif" color="#000000"&gt;order by &lt;STRONG&gt;&lt;FONT color="#800000"&gt;&lt;EM&gt;table.name&lt;/EM&gt; &lt;/FONT&gt;&lt;/STRONG&gt;desc;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif" color="#000000"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 16:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905385#M357608</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2023-11-30T16:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Old macro ps from RAND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905389#M357611</link>
      <description>&lt;P&gt;Must is come to this? I go into the preceding CSV file and manually alter table.name to table_name. Then I may run the remainder of the macro as a separate macro.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;proc import datafile="&amp;amp;path/baltab.csv"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;out=_baltab&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;dbms=csv&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;replace;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;getnames=yes;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;datarow=2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;guessingrows=MAX;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;proc sql noprint;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;select distinct&lt;EM&gt;&lt;FONT color="#800000"&gt;&lt;STRONG&gt; table_name&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;into :elements separated by " "&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;from _baltab&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;order by &lt;EM&gt;&lt;FONT color="#800000"&gt;&lt;STRONG&gt;table_name&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/EM&gt; desc;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;* %put &amp;amp;elements;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;unw ks.max.ATT es.mean.ATT&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 17:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905389#M357611</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2023-11-30T17:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Old macro ps from RAND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905397#M357616</link>
      <description>&lt;P&gt;Just set VALIDVARNAME option to V7 before running the PROC IMPORT and you will get a dataset with valid SAS variable names instead of names with periods and other invalid characters in them.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 17:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905397#M357616</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-30T17:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Old macro ps from RAND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905409#M357620</link>
      <description>Thank you, but this would also change the names of stat parameters in that&lt;BR /&gt;table. I just want to change table.name to table_name.&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Nov 2023 19:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905409#M357620</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2023-11-30T19:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Old macro ps from RAND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905411#M357621</link>
      <description>&lt;P&gt;So the other variables also have goofy names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The RENAME statement or RENAME= dataset option can rename a variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  rename 'table.name'n=table_name;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Nov 2023 19:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905411#M357621</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-30T19:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: Old macro ps from RAND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905429#M357625</link>
      <description>I tried a literal. SAS would still complain. It does not like the dot. The funny thing is that csv with table.name variable is mostly for show. I can remove that part of the ps macro altogether.&lt;BR /&gt;It is pretty short, and most of the output is produced before.</description>
      <pubDate>Thu, 30 Nov 2023 20:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905429#M357625</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2023-11-30T20:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Old macro ps from RAND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905434#M357628</link>
      <description>&lt;P&gt;Log? Actual log contents? And since this apparently involves a macro then run with Options MPRINT.&lt;/P&gt;
&lt;P&gt;You do not show exactly what SAS "complains" about. As in what the log says.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you are providing all the information.&lt;/P&gt;
&lt;P&gt;Before you attempted a dataset name literal did you set Options Validvarname=any; ? That is required to reference data set variable name literals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No complaints with this:&lt;/P&gt;
&lt;PRE&gt;options validvarname=any;
data _baltab;
  'table.name'n='some garbage';
run;

proc sql noprint;
select distinct 'table.name'n
into :elements separated by " "
from _baltab
order by 'table.name'n desc;
quit;

%put elements are: &amp;amp;elements;&lt;/PRE&gt;
&lt;P&gt;And the log:&lt;/P&gt;
&lt;PRE&gt;249  options validvarname=any;
250  data _baltab;
251    'table.name'n='some garbage';
252  run;

NOTE: The data set WORK._BALTAB has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


253
254  proc sql noprint;
255  select distinct 'table.name'n
256  into :elements separated by " "
257  from _baltab
258  order by 'table.name'n desc;
259  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


260  %put elements are: &amp;amp;elements;
elements are: some garbage
&lt;/PRE&gt;
&lt;P&gt;So pretty much have to assume how ever you attempted to use a name literal was incorrect syntax.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 20:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905434#M357628</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-11-30T20:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Old macro ps from RAND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905475#M357641</link>
      <description>&lt;P&gt;Woops, in the evening it works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;proc import datafile="&amp;amp;path/baltab_dot.csv"&lt;BR /&gt;out=_baltab&lt;BR /&gt;dbms=csv&lt;BR /&gt;replace;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;datarow=2;&lt;BR /&gt;guessingrows=MAX;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;set _baltab;&lt;BR /&gt;rename 'table.name'n = table_name;&lt;BR /&gt;run;&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="pink_poodle_0-1701384839897.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90518i11A190343721644F/image-size/large?v=v2&amp;amp;px=999" role="button" title="pink_poodle_0-1701384839897.png" alt="pink_poodle_0-1701384839897.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 22:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905475#M357641</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2023-11-30T22:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Old macro ps from RAND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905476#M357642</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;you were right - incorrect syntax:&lt;/P&gt;
&lt;P&gt;rename "table.name"/n = table_name;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 23:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Old-macro-ps-from-RAND/m-p/905476#M357642</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2023-11-30T23:01:32Z</dc:date>
    </item>
  </channel>
</rss>

