<?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: Assign -ve numeric value to macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944634#M370110</link>
    <description>It sounds like you might want to use formats. What's the final use? &lt;BR /&gt;&lt;BR /&gt;Otherwise you can call the variable something like MINUS1.</description>
    <pubDate>Thu, 19 Sep 2024 18:14:35 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2024-09-19T18:14:35Z</dc:date>
    <item>
      <title>Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944625#M370104</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to assign -ve numeric value to a macro variable in SAS symput statement but getting error below.&lt;/P&gt;&lt;PRE&gt;data one;
infile datalines;
input ID value ;
datalines;
-1 1234
-2 4567
-3 7890
-4 4321
;
run;

data two;
set one;
call symput ( ID,value);
run;&lt;/PRE&gt;&lt;P&gt;ERROR: Symbolic variable name -1 must begin with a letter or underscore.&lt;/P&gt;&lt;P&gt;Is there a way we can use -ve values without getting any error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kajal&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 17:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944625#M370104</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2024-09-19T17:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944627#M370105</link>
      <description>You're using the value as the variable name. Variable names cannot contain a hyphen.</description>
      <pubDate>Thu, 19 Sep 2024 17:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944627#M370105</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-09-19T17:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944628#M370106</link>
      <description>&lt;P&gt;There's no such thing as a macro variable whose name is -1. (Of course, you can have a macro variable with a valid name whose &lt;EM&gt;value&lt;/EM&gt; is -1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain in words what you are trying to do here.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 17:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944628#M370106</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-09-19T17:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944630#M370107</link>
      <description>&lt;P&gt;I am trying to create macro variable values from ID values whose values are under column 'value'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-1 will have a value 1234&lt;/P&gt;&lt;P&gt;-2 will have a value 4567&lt;/P&gt;&lt;P&gt;-3 will have a value 7890&lt;/P&gt;&lt;P&gt;-4 will have a value 4321&amp;nbsp;&lt;/P&gt;&lt;P&gt;like this&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 18:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944630#M370107</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2024-09-19T18:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944631#M370108</link>
      <description>Read the replies again. You can't do that.</description>
      <pubDate>Thu, 19 Sep 2024 18:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944631#M370108</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-09-19T18:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944632#M370109</link>
      <description>&lt;P&gt;How exactly do expect to use that not-legally named variable?&lt;/P&gt;
&lt;P&gt;This smells like trying to put way too much data into macro variables.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 18:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944632#M370109</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-19T18:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944634#M370110</link>
      <description>It sounds like you might want to use formats. What's the final use? &lt;BR /&gt;&lt;BR /&gt;Otherwise you can call the variable something like MINUS1.</description>
      <pubDate>Thu, 19 Sep 2024 18:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944634#M370110</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-09-19T18:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944658#M370121</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259983"&gt;@kajal_30&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to create macro variable values from ID values whose values are under column 'value'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-1 will have a value 1234&lt;/P&gt;
&lt;P&gt;-2 will have a value 4567&lt;/P&gt;
&lt;P&gt;-3 will have a value 7890&lt;/P&gt;
&lt;P&gt;-4 will have a value 4321&amp;nbsp;&lt;/P&gt;
&lt;P&gt;like this&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Explain why you want a macro variable to be named -1. Why does it have to be named -1, why can't it be named POMEGRANATE or ELEPHANT? How will this macro variable be used?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 19:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944658#M370121</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-09-19T19:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944660#M370122</link>
      <description>&lt;P&gt;Is it possible to create format in sas without using hardcoded values but values from columns&amp;nbsp; ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 19:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944660#M370122</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2024-09-19T19:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944662#M370123</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259983"&gt;@kajal_30&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is it possible to create format in sas without using hardcoded values but values from columns&amp;nbsp; ?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes. You have to create a data set with the needed values in the for specific variable names that the procedure expects to see.&lt;/P&gt;
&lt;PRE&gt;data one;
infile datalines;
input ID value ;
datalines;
-1 1234
-2 4567
-3 7890
-4 4321
;
run;

data fmtmaker;
  set one;
  fmtname='Id_to_Value';
  type='N';
  start=Id;
  label=Value;
run;

proc format library=work cntlin=fmtmaker;
run;

proc print data=one;
  var id;
  format id id_to_value.;
run;&lt;/PRE&gt;
&lt;P&gt;There are some elements a bit tricky about ranges of values the Other option in proc format for what to do with not listed values and whether you actually need a FORMAT or an INFORMAT.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 19:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944662#M370123</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-19T19:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944671#M370131</link>
      <description>&lt;P&gt;Thanks but it won't resolve my purpose as I need to use those values in a table name for fetching info.&lt;/P&gt;&lt;P&gt;for eg: &amp;amp;var = 2401 then use this value for where table_name = dt_&amp;amp;var. where I can not use format values like this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 20:46:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944671#M370131</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2024-09-19T20:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944673#M370132</link>
      <description>&lt;P&gt;That is not a very clear description of how you are attempting to use this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any place you have the variable ID you can retrieve the text&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tablename = cats('dt_',put(id, id_to_value.));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And throwing around macro variables with values, where they are assigned or context doesn't clarify much.&lt;/P&gt;
&lt;P&gt;Show the values you need, where you need them.&lt;/P&gt;
&lt;P&gt;What you start with.&lt;/P&gt;
&lt;P&gt;And we may be able to get there.&lt;/P&gt;
&lt;P&gt;Assuming 'this won't work' without a clear description of what it is to be used for results in poor suggestions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if this related to the &lt;A href="https://communities.sas.com/t5/SAS-Programming/Need-help-with-the-code-for-fetching-data-from-different/m-p/944602#M370093" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Need-help-with-the-code-for-fetching-data-from-different/m-p/944602#M370093&lt;/A&gt; post then why haven't you responded to suggestions there?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 20:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944673#M370132</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-19T20:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944675#M370133</link>
      <description>&lt;P&gt;Exactly because I am trying a workaround and as I already clarified that I have values which I need to use to concatenate with other value to create a table name just a simple 1 line ask&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have a value -2 associated to another value 1234&amp;nbsp;&lt;/P&gt;&lt;P&gt;so I need to use 1234 in the table name that's it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 21:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944675#M370133</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2024-09-19T21:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944677#M370135</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259983"&gt;@kajal_30&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Exactly because I am trying a workaround and as I already clarified that I have values which I need to use to concatenate with other value to create a table name just a simple 1 line ask&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;have a value -2 associated to another value 1234&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so I need to use 1234 in the table name that's it.&amp;nbsp;&amp;nbsp;&lt;/P&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;So, how does this not meet the need, using the format created above:&lt;/P&gt;
&lt;PRE&gt;Tablename = cats('dt_',put(id, id_to_value.));&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 21:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944677#M370135</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-19T21:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944679#M370136</link>
      <description>&lt;P&gt;so you are suggesting below ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;select * from sashelp.car_summary_cats('dt_',put(id, id_to_value.));&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expecting it to resolve as below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;select * from sashelp.car_summary_2412;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 21:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944679#M370136</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2024-09-19T21:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944680#M370137</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259983"&gt;@kajal_30&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;so you are suggesting below ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;BR /&gt;select * from sashelp.car_summary_cats('dt_',put(id, id_to_value.));&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;expecting it to resolve as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;BR /&gt;select * from sashelp.car_summary_2412;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is that the SAS code you are trying to generate?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from sashelp.car_summary_2412&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What part of that SAS code needs to VARY?&amp;nbsp; Is it just the 2412?&amp;nbsp; If so then put that into a macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=2412;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then use the macro variable in your code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from sashelp.car_summary_&amp;amp;mvar.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now where does the 2412 come from?&amp;nbsp; How do you know when to use it?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 21:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944680#M370137</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-19T21:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944681#M370138</link>
      <description>&lt;P&gt;No, but then I had zero, nada, no idea of how you expected to use the values because you have not shared that.&lt;/P&gt;
&lt;P&gt;However you can use a data step to create code to execute that way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259983"&gt;@kajal_30&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;so you are suggesting below ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;BR /&gt;select * from sashelp.car_summary_cats('dt_',put(id, id_to_value.));&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;expecting it to resolve as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;BR /&gt;select * from sashelp.car_summary_2412;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Either of those SQL results are poor as they are sending the output to the results window. Not very useful. If you can build a string with the code such as :&lt;/P&gt;
&lt;PRE&gt;data junk;
   length longstring $ 2000;
   longstring = "Proc sql;
select * from sashelp.car_summary_"||put(-1, id_to_value.)||';quit';
run;  &lt;/PRE&gt;
&lt;P&gt;Then you can use Call Execute to use the code in the Longstring, OR write the statements to a text file with a .SAS extension, not needed but helpful later, and %include that file which will treat the contents a code and execute.&lt;/P&gt;
&lt;P&gt;If you have a data set with with ID values that might look like:&lt;/P&gt;
&lt;PRE&gt;data _null_;
/* this has values of ID in it*/
   set somedataset; 

   length longstring $ 2000;
   longstring = "Proc sql;
select * from sashelp.car_summary_"||put(id, id_to_value.)||';quit';

   call execute (longstring);
run;   
&lt;/PRE&gt;
&lt;P&gt;Which would execute that Proc Sql call for every value of ID in the data set.&lt;/P&gt;
&lt;P&gt;I would think actual sql would likely have a "Create table " perhaps using that same put(id, id_to_value.) as part of the output data set name&lt;/P&gt;
&lt;PRE&gt;data _null_;
/* this has values of ID in it*/
   set somedataset; 

   length longstring $ 2000;
   longstring = "Proc sql; Create table mylib.output_"||put(id, id_to_value.)||
"as select * from sashelp.car_summary_"||put(id, id_to_value.)||";quit";

   call execute (longstring);
run;   &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 13:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944681#M370138</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-20T13:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944682#M370139</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;Proc sql;&lt;BR /&gt;select * from sashelp.car_summary_cats('dt_',put(id, id_to_value.));&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I suppose ID would be a macro variable for this to be viable? Then you can write something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from sashelp.car_summary_dt_%sysfunc(putn(&amp;amp;id, id_to_value. -l));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2024 22:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944682#M370139</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-09-19T22:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944683#M370140</link>
      <description>&lt;P&gt;You need to make valid macro variable names.&amp;nbsp; -1 (or actually the way you ran it 10 spaces followed by -1) does not form a valid macro variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you can just convert the hyphen into an underscore?&amp;nbsp; &amp;nbsp;Also no need to make a second dataset if the goal of the step is just to make the macro variables.&amp;nbsp; Use a DATA _NULL_ step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set one;
  call symputX('MVAR'||translate(cats(ID),'__','-.'),value);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's test it out by running putting them into an otherwise empty symbol table so it is easier to see the results.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input ID value ;
datalines;
-1 1234
-2 4567
-3 7890
-4 4321
;

%macro test;
data _null_;
  set one;
  call symputX('MVAR'||translate(cats(ID),'__','-.'),value,'L');
run;
%put _local_ ;
%mend test;
%test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;NOTE: There were 4 observations read from the data set WORK.ONE.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


TEST MVAR_1 1234
TEST MVAR_2 4567
TEST MVAR_3 7890
TEST MVAR_4 4321
&lt;/PRE&gt;
&lt;P&gt;But why are you converting ALL of them into macro variables?&amp;nbsp; Can't you just leave the values in the dataset and convert them into macro variables (or perhaps straight into code) when you actually need it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS You almost never want to use CALL SYMPUT().&amp;nbsp; CALL SYMPUTX() has been available since at least version 6 of SAS (over 30 years).&amp;nbsp; The only reason to use CALL SYMPUT() is if you want the macro variables to contain leading and/or trailing spaces.&amp;nbsp; Something I really doubt that want for this application.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 22:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944683#M370140</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-19T22:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Assign -ve numeric value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944685#M370142</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259983"&gt;@kajal_30&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Exactly because I am trying a workaround and as I already clarified that I have values which I need to use to concatenate with other value to create a table name just a simple 1 line ask&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;have a value -2 associated to another value 1234&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so I need to use 1234 in the table name that's it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So why do you need a macro variable named -2? Why not create a lookup table where you look up -2 and then you retrieve the value 1234? All this can be done in a SAS data set, no macros needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are too tightly focused on the need for a macro variable, which as we explained cannot be named -2. We are trying to propose other ways to get you there, but to do that, we need you to step back and explain the problem at a high level, and not at the "I must have a macro variable" level. This focus on a particular piece of coding you want is usually a bad thing, because it prevents us from suggesting better ways to handle the problem. This is called the &lt;A href="https://en.wikipedia.org/wiki/XY_problem" target="_self"&gt;XY problem&lt;/A&gt; and is not a good way to proceed.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 22:49:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-ve-numeric-value-to-macro-variable/m-p/944685#M370142</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-09-19T22:49:04Z</dc:date>
    </item>
  </channel>
</rss>

