<?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: using a variable in data _null_ in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632820#M187653</link>
    <description>&lt;P&gt;Can you describe more about what your are trying to do, or what results your are expecting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code runs without errors, the log is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    %let clname = eaton;
2
3    data _null_;
4
5    if &amp;amp;clname. = bob then put '5xxxx';
6
7    else put 'yyyy';
8
9    run;

NOTE: Variable eaton is uninitialized.
NOTE: Variable bob is uninitialized.
5xxxx
&lt;/PRE&gt;
&lt;P&gt;Since there is no variable named EATON or BOB, they are created as numeric variables with missing values, and the comparison is true.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you perhaps want to compare the string "eaton" to the string "bob"?&amp;nbsp; If so, you need to add quotes around the string values, so that SAS knows they are not variable names:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;10   %let clname = eaton;
11
12   data _null_;
13
14   if "&amp;amp;clname." = "bob" then put '5xxxx';
15
16   else put 'yyyy';
17
18   run;

yyyy
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Mar 2020 23:03:10 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2020-03-17T23:03:10Z</dc:date>
    <item>
      <title>using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632816#M187650</link>
      <description>&lt;P&gt;I've tried various ways to do this but I'm stumped. I want to use a variable in data _null_ to make a decision. Something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; clname = eaton;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;clname.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = bob &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;put&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'5xxxx'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; put &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'yyyy'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 22:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632816#M187650</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2020-03-17T22:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632819#M187652</link>
      <description>&lt;P&gt;You have to understand how macro variables work. When you run the program, &amp;amp;clname is replaced by its value, eaton. That's all it does in this case. And whatever results must be legal valid working SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, in your case, the line of code with &amp;amp;clname, when executed, is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if eaton = bob then put '5xxxx';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is this what you want? Can you spot a possible problem here? Is this legal valid WORKING code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain, in words, what you want this code to do? Because really, if we're going to help here, we need to know what you want this code to do.&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Mar 2020 23:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632819#M187652</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-17T23:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632820#M187653</link>
      <description>&lt;P&gt;Can you describe more about what your are trying to do, or what results your are expecting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code runs without errors, the log is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    %let clname = eaton;
2
3    data _null_;
4
5    if &amp;amp;clname. = bob then put '5xxxx';
6
7    else put 'yyyy';
8
9    run;

NOTE: Variable eaton is uninitialized.
NOTE: Variable bob is uninitialized.
5xxxx
&lt;/PRE&gt;
&lt;P&gt;Since there is no variable named EATON or BOB, they are created as numeric variables with missing values, and the comparison is true.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you perhaps want to compare the string "eaton" to the string "bob"?&amp;nbsp; If so, you need to add quotes around the string values, so that SAS knows they are not variable names:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;10   %let clname = eaton;
11
12   data _null_;
13
14   if "&amp;amp;clname." = "bob" then put '5xxxx';
15
16   else put 'yyyy';
17
18   run;

yyyy
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 23:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632820#M187653</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-03-17T23:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632823#M187654</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You have to understand how macro variables work. When you run the program, &amp;amp;clname is replaced by its value, eaton. That's all it does in this case. And whatever results must be legal valid working SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, in your case, the line of code with &amp;amp;clname, when executed, is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if eaton = bob then put '5xxxx';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is this what you want? Can you spot a possible problem here? Is this legal valid WORKING code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain, in words, what you want this code to do? Because really, if we're going to help here, we need to know what you want this code to do.&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the variable clname resolves to bob I want to print "5xxxx", otherwise I want to print "yyyy"&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 23:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632823#M187654</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2020-03-17T23:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632825#M187656</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can you describe more about what your are trying to do, or what results your are expecting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code runs without errors, the log is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    %let clname = eaton;
2
3    data _null_;
4
5    if &amp;amp;clname. = bob then put '5xxxx';
6
7    else put 'yyyy';
8
9    run;

NOTE: Variable eaton is uninitialized.
NOTE: Variable bob is uninitialized.
5xxxx
&lt;/PRE&gt;
&lt;P&gt;Since there is no variable named EATON or BOB, they are created as numeric variables with missing values, and the comparison is true.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you perhaps want to compare the string "eaton" to the string "bob"?&amp;nbsp; If so, you need to add quotes around the string values, so that SAS knows they are not variable names:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;10   %let clname = eaton;
11
12   data _null_;
13
14   if "&amp;amp;clname." = "bob" then put '5xxxx';
15
16   else put 'yyyy';
17
18   run;

yyyy
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I want to have a variable that I can set to a value, in case "eaton" and then inside the data _null_ I want to evaluate that variable and if it is "eaton", I'll do one thing and if it's not "eaton" I'll do something else.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 23:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632825#M187656</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2020-03-17T23:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632826#M187657</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49285"&gt;@DanD999&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the variable clname resolves to bob I want to print "5xxxx", otherwise I want to print "yyyy"&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;HINT: before you try to write code with macro variables, you need to get the code to work without macro variables, in other words, make this code work with purely DATA step code. I don't think you have done that; and if you are able to do that, then getting the macro to work is easy. And if you can't get the DATA step code to work, then you will probably never get the macro code to work. Can you show us working data step code with no macro variables that does what you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why doesn't your&amp;nbsp; code work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clname is a macro variable with the value eaton. When this macro variable is resolved in a data step, eaton is the name of a variable which apparently doesn't exist. also, bob is the name of a variable that doesn't exist. So you are comparing variable eaton, which doesn't exist, to variable bob, which doesn't exist. That doesn't sound like what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you want to compare the text string "eaton" to the text string "bob". If this is what you want to do (is it?), you should be able to make some extremely minor changes to your code to do this string comparison.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Mar 2020 23:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632826#M187657</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-17T23:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632827#M187658</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49285"&gt;@DanD999&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You have to understand how macro variables work. When you run the program, &amp;amp;clname is replaced by its value, eaton. That's all it does in this case. And whatever results must be legal valid working SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, in your case, the line of code with &amp;amp;clname, when executed, is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if eaton = bob then put '5xxxx';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is this what you want? Can you spot a possible problem here? Is this legal valid WORKING code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain, in words, what you want this code to do? Because really, if we're going to help here, we need to know what you want this code to do.&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the variable clname resolves to bob I want to print "5xxxx", otherwise I want to print "yyyy"&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you're making this more complicated than it is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm setting a variable outside of the data _null_ to a value, in this case "eaton". I want to use that variable inside of the data _null_ to make a decision. How do I get the data _null_ to recognize that I've set the variable "clname" to "eaton" on the outside and use it on the inside?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 23:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632827#M187658</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2020-03-17T23:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632829#M187660</link>
      <description>&lt;P&gt;But you don't have a variable with the named CLNAME.&amp;nbsp; In fact you did not create any variables in your code (other than accidentally by referencing the variables EATON and BOB that hadn't been defined yet).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You created a MACRO VARIABLE with that name.&amp;nbsp; To test the value of a macro variable in SAS code (as opposed to macro code) you need to either resolve it inside of double quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if "&amp;amp;clname" = 'bob' then put '5xxxx';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use the SYMGET() function. The SYMGET() function wants a character value that is the name of the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if symget('clname') = 'bob' then put '5xxxx';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You would normally not need to use that as the value of CLNAME will not normally change while the data step is running.&amp;nbsp; If it did change (for example because the data step had earlier used the CALL SYMPUTX() function) then it might make sense.&amp;nbsp; Or if the value of CLNAME is something that would confuse SAS when it tried to evaluate "&amp;amp;clname".&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 23:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632829#M187660</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-17T23:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632831#M187662</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But you don't have a variable with the named CLNAME.&amp;nbsp; In fact you did not create any variables in your code (other than accidentally by referencing the variables EATON and BOB that hadn't been defined yet).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You created a MACRO VARIABLE with that name.&amp;nbsp; To test the value of a macro variable in SAS code (as opposed to macro code) you need to either resolve it inside of double quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if "&amp;amp;clname" = 'bob' then put '5xxxx';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use the SYMGET() function. The SYMGET() function wants a character value that is the name of the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if symget('clname') = 'bob' then put '5xxxx';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You would normally not need to use that as the value of CLNAME will not normally change while the data step is running.&amp;nbsp; If it did change (for example because the data step had earlier used the CALL SYMPUTX() function) then it might make sense.&amp;nbsp; Or if the value of CLNAME is something that would confuse SAS when it tried to evaluate "&amp;amp;clname".&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks Tom.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Symget is the way to get the value of the variable on the outside of the data _null_ into the data _null_&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symget(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'client'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'eaton'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symputx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'start_dt'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;sas_run_date.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'beg'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;),&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;yymmddn8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; call symputx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'start_dt'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"'"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;|| put(&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;sas_beg_dt.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) ||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"'"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ===&amp;gt; start_dt = &amp;amp;start_dt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thank you Quentin and PaigeMiller for responding.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 23:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632831#M187662</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2020-03-17T23:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632833#M187663</link>
      <description>&lt;P&gt;A macro variable (or macro symbol) is &lt;STRONG&gt;NOT A VARIABLE.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 23:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632833#M187663</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-17T23:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632835#M187665</link>
      <description>&lt;P&gt;Macro variables resolve before the data step executes. So from a SAS data step perspective you're just dealing with a string.&lt;/P&gt;
&lt;P&gt;Strings need to be in quotes. AND for macro variables to resolve they need to be in double quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let clname = eaton;
data _null_;
  if "%upcase(&amp;amp;clname)" = "BOB" then put 'xxxx';
  else if "%upcase(&amp;amp;clname)" = "EATON" then put 'yyyy';
  else put 'zzzz';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Mar 2020 00:32:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632835#M187665</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-18T00:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: using a variable in data _null_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632982#M187734</link>
      <description>&lt;P&gt;Thanks for an alternate way Patrick.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 15:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-a-variable-in-data-null/m-p/632982#M187734</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2020-03-18T15:07:39Z</dc:date>
    </item>
  </channel>
</rss>

