<?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: Proc SQL Code working in SAS 9.4 but not SAS 9.3 -  nvar to variable not setting properly? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285181#M59398</link>
    <description>Thanks ksharp -- your solution actually fixes the original issue also -- the case-sensitivity of libname reference.&lt;BR /&gt;&lt;BR /&gt;Much appreciated, sir.</description>
    <pubDate>Mon, 18 Jul 2016 09:22:24 GMT</pubDate>
    <dc:creator>chrisengel</dc:creator>
    <dc:date>2016-07-18T09:22:24Z</dc:date>
    <item>
      <title>Proc SQL Code working in SAS 9.4 but not SAS 9.3 -  nvar to variable not setting properly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285174#M59393</link>
      <description>&lt;P&gt;I'm trying to use a simple batch renaming macro to simplify a project, here's the SUGI paper:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings09/075-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/075-2009.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Creating a dataset */
DATA A;
input id $4. before_var1_after before_var2_after before_var3_after;
datalines;
i001 1 2 3
i002 3 4 5
i003 6 7 8
i004 9 10 12
;
run;

/* Adding Prefix on all variables */
%macro rename(lib,dsn,newname);
proc contents data=&amp;amp;lib..&amp;amp;dsn;
title 'before renaming';
run;
proc sql noprint;
 select nvar into :num_vars
 from dictionary.tables
 where libname="&amp;amp;LIB" and memname="&amp;amp;DSN";
 select distinct(name) into :var1-:var%trim(%left(&amp;amp;num_vars))
 from dictionary.columns
 where libname="&amp;amp;LIB" and memname="&amp;amp;DSN";
 quit;
run;
proc datasets library = &amp;amp;LIB;
modify &amp;amp;DSN;
rename
%do i = 1 %to &amp;amp;num_vars.;
&amp;amp;&amp;amp;var&amp;amp;i = &amp;amp;newname._&amp;amp;&amp;amp;var&amp;amp;i.
%end;
;
quit;
run;
proc contents data=&amp;amp;lib..&amp;amp;dsn.;
title 'after renaming';
run;
%mend rename;
DATA B;
set A;
run;
%rename(WORK,B,Try1); &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The raw test code seems to work fine in a local 9.4 version of SAS, but when I copy word for word this code into SAS 9.3 on a server, it doesn't work. I get the following error printed to log (and SAS freezes, forcing me to kill the process to restart it):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: no rows were selected.&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference NUM_VARS not resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NOTE: Line generated by the macro function "SUBSTR".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp;var&amp;amp;num_vars&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;26&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ERROR 22-322 Syntax error, expecting one of the following: ','|,FROM, NOTRIM.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So, it seems like the proc sql of select nvar into :num_vars is failing. Or am I missing something?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;One thing I should add: I can't copy and paste code into the server because of how the security settings are, so maybe it's as simple as a typo from the code, but I have checked it a few times and can't figure it out.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help would be appreciated, thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;EDIT:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ive isolated the proc sql to run it and see:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
 select nvar into :num_vars
 from dictionary.tables
 where libname="WORK" and memname="B";
NOTE: NO rows were selected&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;So it gives me an error just in the basic checking of the num vars from the dataset, which exists. Why would it fire this No rows selected error?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 08:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285174#M59393</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-07-18T08:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Code working in SAS 9.4 but not SAS 9.3 -  nvar to variable not setting properly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285175#M59394</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The NOTE about no rows selection means that there is &lt;STRONG&gt;no&lt;/STRONG&gt; dataset B in the WORK library.&lt;/P&gt;
&lt;P&gt;You shall check the condition&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;libname&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"WORK"&lt;/SPAN&gt; and memname&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"B"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 09:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285175#M59394</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-07-18T09:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Code working in SAS 9.4 but not SAS 9.3 -  nvar to variable not setting properly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285179#M59396</link>
      <description>&lt;P&gt;That code is too clumsy . Try this one .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro rename(lib,dsn,newname);
 data _null_;
  set sashelp.vcolumn(where=(libname="%upcase(&amp;amp;lib)" and memname="%upcase(&amp;amp;dsn)")) end=last;
  if _n_=1 then call execute("proc datasets library=&amp;amp;lib  nodetails nolist;modify &amp;amp;dsn;rename ");
  call execute(catt(name,'=&amp;amp;newname._',name));
  if last then call execute(';quit;');
 run;
%mend rename;
DATA B;
set sashelp.class;
run;
%rename(WORK,B,Try1) &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 09:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285179#M59396</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-18T09:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Code working in SAS 9.4 but not SAS 9.3 -  nvar to variable not setting properly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285180#M59397</link>
      <description>&lt;P&gt;Hi Loko,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for the response. you helped me to focus on this issue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I have figured it out: the Proc SQL is case sensitive on the libname references, so i was using "Work" not "WORK" in the macro.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 09:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285180#M59397</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-07-18T09:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Code working in SAS 9.4 but not SAS 9.3 -  nvar to variable not setting properly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285181#M59398</link>
      <description>Thanks ksharp -- your solution actually fixes the original issue also -- the case-sensitivity of libname reference.&lt;BR /&gt;&lt;BR /&gt;Much appreciated, sir.</description>
      <pubDate>Mon, 18 Jul 2016 09:22:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285181#M59398</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-07-18T09:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Code working in SAS 9.4 but not SAS 9.3 -  nvar to variable not setting properly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285186#M59399</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;I am wondering if something similar can be done to "Relabel", is there a proc datasets that can be used to modify the dataset by relabeling the variables in additio nto rename? So the existing label should be intact, but with the prefix (or suffix, as i have modified the code to have) being applied.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any pointers in the right direction would be appreciated, thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 09:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285186#M59399</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-07-18T09:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Code working in SAS 9.4 but not SAS 9.3 -  nvar to variable not setting properly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285190#M59402</link>
      <description>&lt;P&gt;Yes. Just change RENAME into LABEL.&lt;/P&gt;
&lt;P&gt;But better post an example to explain your question.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 09:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285190#M59402</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-18T09:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Code working in SAS 9.4 but not SAS 9.3 -  nvar to variable not setting properly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285191#M59403</link>
      <description>I will try it and then post a new question in a new thread to be solved if there's an issue (thanks again)</description>
      <pubDate>Mon, 18 Jul 2016 09:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Code-working-in-SAS-9-4-but-not-SAS-9-3-nvar-to/m-p/285191#M59403</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-07-18T09:55:36Z</dc:date>
    </item>
  </channel>
</rss>

