<?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 Set macro variable in data null. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621004#M182513</link>
    <description>&lt;P&gt;I'm trying to loop through a table and call a macro.&amp;nbsp; Before I call the macro I'd like to set the value of a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%global curProgram;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table AllProgramList (&lt;BR /&gt;SMRPRLE_PROGRAM varchar(100)&lt;BR /&gt;);&lt;BR /&gt;insert into AllProgramList(SMRPRLE_PROGRAM) values ("One");&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data _null_; set AllProgramList; &lt;BR /&gt;file code;&lt;BR /&gt;put '%let curProgram = bquote('SMRPRLE_PROGRAM +(-1)')';&lt;BR /&gt;/*put '%setProgramClause()';&lt;BR /&gt;put '%callStudentBody(No)'; */&lt;BR /&gt;run; &lt;BR /&gt;%put curProgram &amp;amp;curProgram;&lt;BR /&gt;%include code / source2;&lt;/PRE&gt;
&lt;P&gt;Why does&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '%let curProgram = bquote('SMRPRLE_PROGRAM +(-1)')';&lt;/P&gt;
&lt;P&gt;Make this error message then not set the value of curProgram?&lt;BR /&gt;49&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space &lt;BR /&gt;between a quoted string and the succeeding identifier is recommended.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jan 2020 22:16:11 GMT</pubDate>
    <dc:creator>DavidPhillips2</dc:creator>
    <dc:date>2020-01-29T22:16:11Z</dc:date>
    <item>
      <title>Set macro variable in data null.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621004#M182513</link>
      <description>&lt;P&gt;I'm trying to loop through a table and call a macro.&amp;nbsp; Before I call the macro I'd like to set the value of a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%global curProgram;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table AllProgramList (&lt;BR /&gt;SMRPRLE_PROGRAM varchar(100)&lt;BR /&gt;);&lt;BR /&gt;insert into AllProgramList(SMRPRLE_PROGRAM) values ("One");&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data _null_; set AllProgramList; &lt;BR /&gt;file code;&lt;BR /&gt;put '%let curProgram = bquote('SMRPRLE_PROGRAM +(-1)')';&lt;BR /&gt;/*put '%setProgramClause()';&lt;BR /&gt;put '%callStudentBody(No)'; */&lt;BR /&gt;run; &lt;BR /&gt;%put curProgram &amp;amp;curProgram;&lt;BR /&gt;%include code / source2;&lt;/PRE&gt;
&lt;P&gt;Why does&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '%let curProgram = bquote('SMRPRLE_PROGRAM +(-1)')';&lt;/P&gt;
&lt;P&gt;Make this error message then not set the value of curProgram?&lt;BR /&gt;49&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space &lt;BR /&gt;between a quoted string and the succeeding identifier is recommended.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 22:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621004#M182513</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2020-01-29T22:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Set macro variable in data null.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621005#M182514</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5059"&gt;@DavidPhillips2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to loop through a table and call a macro.&amp;nbsp; Before I call the macro I'd like to set the value of a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%global curProgram;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table AllProgramList (&lt;BR /&gt;SMRPRLE_PROGRAM varchar(100)&lt;BR /&gt;);&lt;BR /&gt;insert into AllProgramList(SMRPRLE_PROGRAM) values ("One");&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data _null_; set AllProgramList; &lt;BR /&gt;file code;&lt;BR /&gt;put '%let curProgram = bquote('SMRPRLE_PROGRAM +(-1)')';&lt;BR /&gt;/*put '%setProgramClause()';&lt;BR /&gt;put '%callStudentBody(No)'; */&lt;BR /&gt;run; &lt;BR /&gt;%put curProgram &amp;amp;curProgram;&lt;BR /&gt;%include code / source2;&lt;/PRE&gt;
&lt;P&gt;Why does&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '%let curProgram = bquote('SMRPRLE_PROGRAM +(-1)')';&lt;/P&gt;
&lt;P&gt;Make this error message then not set the value of curProgram?&lt;BR /&gt;49&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space &lt;BR /&gt;between a quoted string and the succeeding identifier is recommended.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It doesn't set any values because you have told the data step to display some text in the log. Not to set a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is not an error. What SAS is telling you that a PUT (or some other statements) with text after a closing quote may in the future be interpreted differently.&lt;/P&gt;
&lt;P&gt;Date literals '01JAN2020'D reserve the D immediately after the quote to treat the quoted value as a date. Similar with Time and T, Datetime and DT and Name literals such as "This is not a typical var"N when the Validvarname=Any is in effect.&lt;/P&gt;
&lt;P&gt;Because you have multiple quotes the text after the second ' the text SMRPRLE is considered "an identifier after a quoted string".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you change&lt;/P&gt;
&lt;PRE&gt;put '%let curProgram = bquote('SMRPRLE_PROGRAM +(-1)')';&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;put '%let curProgram = bquote(' SMRPRLE_PROGRAM +(-1) ')';&lt;/PRE&gt;
&lt;P&gt;the warning will go away but you still aren't creating or setting a macro variable.&lt;/P&gt;
&lt;P&gt;You would use the CALL SYMPUT or CALL SYMPUTX statement to assign the value of a macro variable in a datastep.&lt;/P&gt;
&lt;P&gt;Possibly you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Call symputx('curprogram', "some value") ;&lt;/P&gt;
&lt;P&gt;I suspect that you don't want bquote as part of the macro variable though. MAYBE %bquote but I doubt it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you would have to show us the exact value you expect the macro variable curprogam to have.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 22:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621005#M182514</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-29T22:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Set macro variable in data null.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621006#M182515</link>
      <description>&lt;P&gt;The note has the hint&amp;nbsp; embedded :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space
between a quoted string and the succeeding identifier is recommended.&lt;/PRE&gt;
&lt;P&gt;Inserting a white space after the quote has worked for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;36         data _null_;

37         	set AllProgramList;
38         	file code;
39         	put '%let curProgram =&lt;FONT color="#FF0000"&gt; %bquote('&lt;/FONT&gt; SMRPRLE_PROGRAM +(-1)')';
40         
41         	/*put '%setProgramClause()';
42         	put '%callStudentBody(No)'; */
43         run;



NOTE: 1 record was written to the file CODE.
      The minimum record length was 30.
      The maximum record length was 30.
NOTE: There were 1 observations read from the data set WORK.ALLPROGRAMLIST.&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Jan 2020 22:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621006#M182515</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2020-01-29T22:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Set macro variable in data null.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621055#M182524</link>
      <description>&lt;P&gt;I'm trying to read the value One from the dataset dynamically into curProgram.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 04:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621055#M182524</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2020-01-30T04:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Set macro variable in data null.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621063#M182529</link>
      <description>&lt;P&gt;Your put statement puts &lt;EM&gt;three&lt;/EM&gt; elements (a string, a variable value, another string), so it is a good idea to separate those elements visually in the first place. You should also add the necessary semicolon to end the macro statement created by your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put '%let curProgram = bquote(' SMRPRLE_PROGRAM +(-1) ');';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your program will then create this code in the file referenced by fileref "code":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let curProgram = bquote(One);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is this what you want?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 06:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621063#M182529</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-30T06:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Set macro variable in data null.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621153#M182565</link>
      <description>&lt;P&gt;I think I'm missing something simple in the thread.&amp;nbsp; When I run the below the last line does not print out the value of the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%global curProgram;
proc sql;
create table AllProgramList (
SMRPRLE_PROGRAM varchar(100)
);
insert into AllProgramList(SMRPRLE_PROGRAM) values ("One");
;

 data _null_;

     set AllProgramList;
     file code;
     put '%let curProgram = bquote(' SMRPRLE_PROGRAM +(-1) ');';
 run;
%put curProgram &amp;amp;curProgram;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jan 2020 14:23:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621153#M182565</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2020-01-30T14:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Set macro variable in data null.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621154#M182566</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;look at the comments in the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global curProgram;
proc sql;
create table AllProgramList (
SMRPRLE_PROGRAM varchar(100)
);
insert into AllProgramList(SMRPRLE_PROGRAM) values ("One");
;

filename code TEMP; /* &amp;lt;- create temporary file */
data _null_; set AllProgramList; 
file code;
put '%let curProgram = %bquote(' SMRPRLE_PROGRAM +(-1) ');'; /* &amp;lt;- here: 
0) add spaces around `SMRPRLE_PROGRAM +(-1)` &lt;BR /&gt;&lt;BR /&gt;1) semicolon after macrovariable declaration is missing 
2) it should be '%bquote', not 'bquote'
*/
/*put '%setProgramClause()';
put '%callStudentBody(No)'; */
run; 
%put curProgram &amp;amp;curProgram;
%include code / source2;&lt;BR /&gt;%put curProgram &amp;amp;curProgram;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;log:&lt;/P&gt;&lt;PRE&gt;19    %global curProgram;
20    proc sql;
21    create table AllProgramList (
22    SMRPRLE_PROGRAM varchar(100)
23    );
NOTE: One or more variables were converted because the data type is not supported by the V9
      engine. For more details, run with options MSGLEVEL=I.
NOTE: Table WORK.ALLPROGRAMLIST created, with 0 rows and 1 columns.
24    insert into AllProgramList(SMRPRLE_PROGRAM) values ("One");
NOTE: 1 row was inserted into WORK.ALLPROGRAMLIST.

25    ;
26
27    filename code TEMP;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds


28    data _null_; set AllProgramList;
29    file code;
30    put '%let curProgram = %bquote(' SMRPRLE_PROGRAM +(-1) ');';
31    /*put '%setProgramClause()';
32    put '%callStudentBody(No)'; */
33    run;

NOTE: The file CODE is:
      Filename=C:\SAS_Temporary_Files\computer_name\#LN00241,
      RECFM=V,LRECL=32767,File Size (bytes)=0,
      Last Modified=30Jan2020:15:28:14,
      Create Time=30Jan2020:15:28:14

NOTE: 1 record was written to the file CODE.
      The minimum record length was 31.
      The maximum record length was 31.
NOTE: There were 1 observations read from the data set WORK.ALLPROGRAMLIST.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds


34    %put curProgram &amp;amp;curProgram;
curProgram
35    %include code / source2;
NOTE: %INCLUDE (level 1) file CODE is file
      C:\SAS_Temporary_Files\computer_name\#LN00241.
36   +%let curProgram = %bquote(One);
NOTE: %INCLUDE (level 1) ending.
37
38    %put curProgram &amp;amp;curProgram;
curProgram One&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 14:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621154#M182566</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-01-30T14:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Set macro variable in data null.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621156#M182568</link>
      <description>&lt;P&gt;Slightly shorter code.&amp;nbsp; I didn't realize I could just call the column name directly in this case.&amp;nbsp; the -1 reference in the code was not needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%global curProgram;
proc sql;
create table AllProgramList (
SMRPRLE_PROGRAM varchar(100)
);
insert into AllProgramList(SMRPRLE_PROGRAM) values ("One");
insert into AllProgramList(SMRPRLE_PROGRAM) values ("Two");
;

 data _null_; set AllProgramList;
     file code;
	 Call symputx('curprogram', SMRPRLE_PROGRAM);
 run;
%put curProgram &amp;amp;curProgram;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jan 2020 14:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-macro-variable-in-data-null/m-p/621156#M182568</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2020-01-30T14:37:48Z</dc:date>
    </item>
  </channel>
</rss>

