<?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: Create a macro variable list with quoted values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517050#M139714</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170717"&gt;@vanja&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You are absolutely right. The code looks ok to me too but the macro variable it produces does not work in the value statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this macro variable works. But I would so much like it to by dynamic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let valuesAr1="2002" "2003" "2004" "2005" "2006" "2007" "2008" "2009" "2010" "2011" "2012" "2013" "2014" "2015" "2016" "2017" "2018" "2019";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the macro variable values are the same the code should run the same.&amp;nbsp; If they don't then either there are other changes to the code or the macro variable values are NOT the same.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  do year=2002 to 2019;
    length str $200 ;
    str=catx(' ',str,quote(put(year,4.)));
  end;
  call symputx('valuesAr1',str);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 29 Nov 2018 14:26:49 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-11-29T14:26:49Z</dc:date>
    <item>
      <title>Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/516973#M139669</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I would like to create a macro or a macro&amp;nbsp;variable that returns the following list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"2002" "2003" "2004" "2005" "2006" "2007" "2008" "2009" "2010" "2011" "2012" "2013" "2014" "2015" "2016" "2017" "2018" "2019"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The goal is to produce a value list in an axis statment for proc plot:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code&amp;nbsp;produces a list but still does not work in the axis statement and preferably I would like a macro that returns the list I am after. But I would also be happy to just get a macro variable with a list that works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data valuesYear1;
do year=2002 to 2019;
  qYear=quote(compress(year));
  output;
end;
run;

proc sql noprint;
select qyear into :valuesYear1 separated by ' '
 from valuesYear1;
quit;

axis2 label=none minor=none order=("01jan2002."d to "01jan2019."d by 365.25) value=(&amp;amp;valuesAr1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 09:43:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/516973#M139669</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2018-11-29T09:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/516978#M139674</link>
      <description>&lt;P&gt;First off, drop proc plot.&amp;nbsp; It is very old and has, for a long time, been replaced by sgplot for more functionality and easier use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, creating a list of values like that in a macro variable isn't generally a good idea.&amp;nbsp; First off, do you not want those items to be numeric?&amp;nbsp; That way you can just specify the range like:&lt;/P&gt;
&lt;PRE&gt;proc sgplot...;  
  xaxis values=(2002 to 2019);
...
run;&lt;/PRE&gt;
&lt;P&gt;Much easier, and less coding.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 09:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/516978#M139674</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-29T09:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517004#M139686</link>
      <description>&lt;P&gt;I don't have enough knowledge (or time)&amp;nbsp;to transfer the graphs from proc sgplot to proc gplot and also, there are so many of them in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried with value=(2002 to 2019) in proc gplot but seems not to be supported.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the only thing that seem to work with the current code is to acutally specfiy the value list and I need help in creating that macro or that macro variable.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 11:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517004#M139686</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2018-11-29T11:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517006#M139688</link>
      <description>&lt;P&gt;I don't think you need macro variables here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;axis2 label=none minor=none value=("01jan2002"d to "01jan2019"d by year);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Nov 2018 12:02:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517006#M139688</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-29T12:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517017#M139693</link>
      <description>&lt;P&gt;do you mean order instead of value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;axis2 label=none minor=none order=("01jan2002"d to "01jan2019"d by year);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The statement above with order=&amp;nbsp;works in a way&amp;nbsp;but I get som ugly warnings (which I don't like)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: The intervals on the axis labeled "DATEVAR" are not
         evenly spaced.
WARNING: No minor tick marks will be drawn because major tick
         increments have been specified in uneven or unordered
         intervals.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Nov 2018 12:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517017#M139693</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2018-11-29T12:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517018#M139694</link>
      <description>&lt;P&gt;I'm confused.&amp;nbsp; It looks to me like the code you posted creates the list you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;8    proc sql noprint;
9    select qyear into :valuesYear1 separated by ' '
10    from valuesYear1;
11   quit;

12
13   %put &amp;amp;valuesYear1 ;
"2002" "2003" "2004" "2005" "2006" "2007" "2008" "2009" "2010" "2011" "2012" "2013" "2014" "2015"
"2016" "2017" "2018" "2019"
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe that's not actually the list you need.&amp;nbsp; Maybe try hardcoding the list into your axis statement, and get that working.&amp;nbsp; Then you can go back to making a macro or macro variable that will generate the list.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 12:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517018#M139694</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-11-29T12:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517020#M139695</link>
      <description>&lt;P&gt;You are absolutely right. The code looks ok to me too but the macro variable it produces does not work in the value statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this macro variable works. But I would so much like it to by dynamic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let valuesAr1="2002" "2003" "2004" "2005" "2006" "2007" "2008" "2009" "2010" "2011" "2012" "2013" "2014" "2015" "2016" "2017" "2018" "2019";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 12:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517020#M139695</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2018-11-29T12:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517025#M139700</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170717"&gt;@vanja&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You are absolutely right. The code looks ok to me too but the macro variable it produces does not work in the value statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this macro variable works. But I would so much like it to by dynamic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let valuesAr1="2002" "2003" "2004" "2005" "2006" "2007" "2008" "2009" "2010" "2011" "2012" "2013" "2014" "2015" "2016" "2017" "2018" "2019";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's an important rule. You can't say "does not work". That does not give any information that would be helpful to solve the problem. You need to show us the LOG where you see the error, or show us the output that is not correct, or both.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 13:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517025#M139700</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-29T13:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517026#M139701</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170717"&gt;@vanja&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;do you mean order instead of value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;axis2 label=none minor=none order=("01jan2002"d to "01jan2019"d by year);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The statement above with order=&amp;nbsp;works in a way&amp;nbsp;but I get som ugly warnings (which I don't like)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: The intervals on the axis labeled "DATEVAR" are not
         evenly spaced.
WARNING: No minor tick marks will be drawn because major tick
         increments have been specified in uneven or unordered
         intervals.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I guess these don't bother me at all. All of the January 1 of each year is not evenly spaced once you include a leap year.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 13:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517026#M139701</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-29T13:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517041#M139709</link>
      <description>&lt;P&gt;Well, I'm flummoxed.&amp;nbsp; &amp;nbsp;From what I can see, your hard-coded list is exactly the same as the list generated from the SQL step.&amp;nbsp; I can't see how/why you would get different results.&amp;nbsp; If you're getting errors, please post your log.&amp;nbsp; Or better yet, post a full example which replicates the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my log from generating the list, and comparing it to the hardcoded list to confirm they are the same:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;16   data valuesYear1;
17   do year=2002 to 2019;
18     qYear=quote(compress(year));
19     output;
20   end;
21   run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      18:24
NOTE: The data set WORK.VALUESYEAR1 has 18 observations and 2 variables.

22
23   proc sql noprint;
24   select qyear into :valuesYear1 separated by ' '
25    from valuesYear1;
26   quit;

27
28   %let valuesAr1="2002" "2003" "2004" "2005" "2006" "2007" "2008" "2009" "2010" "2011" "2012"
28 ! "2013" "2014" "2015" "2016" "2017" "2018" "2019";
29
30   %put &amp;gt;&amp;gt;%eval(&amp;amp;valuesYear1=&amp;amp;valuesAr1)&amp;lt;&amp;lt; ;
&amp;gt;&amp;gt;1&amp;lt;&amp;lt;
&lt;/PRE&gt;
&lt;P&gt;If your real data has some macro quoting going on, you can try %unquote(&amp;amp;valuesYear1).&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 13:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517041#M139709</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-11-29T13:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517050#M139714</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170717"&gt;@vanja&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You are absolutely right. The code looks ok to me too but the macro variable it produces does not work in the value statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this macro variable works. But I would so much like it to by dynamic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let valuesAr1="2002" "2003" "2004" "2005" "2006" "2007" "2008" "2009" "2010" "2011" "2012" "2013" "2014" "2015" "2016" "2017" "2018" "2019";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the macro variable values are the same the code should run the same.&amp;nbsp; If they don't then either there are other changes to the code or the macro variable values are NOT the same.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  do year=2002 to 2019;
    length str $200 ;
    str=catx(' ',str,quote(put(year,4.)));
  end;
  call symputx('valuesAr1',str);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Nov 2018 14:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517050#M139714</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-29T14:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517053#M139715</link>
      <description>&lt;P&gt;Thank you for the %eval-code. It made me realize that I was right from the beginning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;gt;&amp;gt;%eval(&amp;amp;valuesYear1=&amp;amp;valuesAr1)&amp;lt;&amp;lt; ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The mistake I made when I wrote "that it didn't work" must have been that I wrote values=("&amp;amp;valuesYear1"), that is I wrote it within quotes. What a stupid mistake. Now my original code actually works.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 14:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517053#M139715</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2018-11-29T14:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517055#M139716</link>
      <description>&lt;P&gt;Thank you so much for trying to help me. When I finally got the macro code to work I stick with my original solution. But I am so grateful for the help and for explaining to me why I got that warning message. Did not at all understand it was because of leap years.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 14:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517055#M139716</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2018-11-29T14:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable list with quoted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517056#M139717</link>
      <description>&lt;P&gt;You are absolutely right, I am a bit uncustomed to ask for help in forums. Next time I will do better.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 14:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-list-with-quoted-values/m-p/517056#M139717</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2018-11-29T14:39:59Z</dc:date>
    </item>
  </channel>
</rss>

