<?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: Macro variable string into several parts divided by commas and quotes. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477906#M286272</link>
    <description>&lt;P&gt;What are you trying to do here? It's not clear what you're attempting and what issues you're having.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're trying to create a list of macro variables, what is your starting source? In general, it's easiest to read the data into SAS as a data set first and then convert to macro variables. See the SQL example below on how to create a macro variable list.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select quote(name) into :name_list separated by ", "
from sashelp.class;
quit;

%put &amp;amp;name_list;&lt;/CODE&gt;&lt;/PRE&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/220909"&gt;@allen_AL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reading. I have a long list with different variables in a macro variable so I can use that list to filter rows.&lt;BR /&gt;%let vars=&lt;BR /&gt;Sxxxf_w&lt;BR /&gt;Sxxxa_w&lt;BR /&gt;Sxxxs_w&lt;BR /&gt;Slxxs_w&lt;BR /&gt;rSddd_w&lt;BR /&gt;Sfssss_w&lt;BR /&gt;Sssss_w&lt;BR /&gt;Sfffb_w&lt;BR /&gt;Sjjjs_w&lt;BR /&gt;Sllls_w&lt;BR /&gt;Ftxxs_w&lt;BR /&gt;Dfxxs_w&lt;BR /&gt;Ltxxs_w&lt;BR /&gt;Ytxxs_w&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*So I can do something like&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select * from DATA&lt;/P&gt;
&lt;P&gt;where variable in ("&lt;SPAN&gt;Sxxxf_w", "&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxa_w","&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxs_w",...)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&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;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*My try:*/&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data filter_list;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187967"&gt;@input&lt;/a&gt; @;&lt;BR /&gt;_infile_=resolve(_infile_);&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187967"&gt;@input&lt;/a&gt; vari $&amp;nbsp; @@ ;&lt;BR /&gt;datalines;&lt;BR /&gt;&amp;amp;vars&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem with this code is that SAS only reads the first 10 lines and if I increase the size of the names, sas reads even less lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jul 2018 15:19:27 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-07-13T15:19:27Z</dc:date>
    <item>
      <title>Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477902#M286271</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for reading. I have a long list with different variables in a macro variable. I want to use that list in a statement like " where variable in ("var1","var2",...) so I can filter rows in a third data set. The vars come from word or somewhere I can't import into SAS. I have to copy and paste this list every time, with different variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A recap of what I am trying to do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have dataset A which contains several records with thousands of variable names in a the column "variables". Kind of like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variable&amp;nbsp; Value1&lt;/P&gt;&lt;P&gt;A 1&lt;BR /&gt;A 1&lt;BR /&gt;A 2&lt;/P&gt;&lt;P&gt;B 1&lt;/P&gt;&lt;P&gt;B 4&lt;/P&gt;&lt;P&gt;C 45&lt;/P&gt;&lt;P&gt;C 56&lt;/P&gt;&lt;P&gt;C 4&lt;/P&gt;&lt;P&gt;F 4&lt;/P&gt;&lt;P&gt;D 2345&lt;/P&gt;&lt;P&gt;D 22&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to filter the rows that contain the Variable "A","C", and "F".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a very simple task, the problem is that the people who will use the macro can only paste the variables they want on&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let vars=&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;C&lt;BR /&gt;F&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Having said that, my code is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let vars=&lt;BR /&gt;Sxxxf_w&lt;BR /&gt;Sxxxa_w&lt;BR /&gt;Sxxxs_w&lt;BR /&gt;Slxxs_w&lt;BR /&gt;rSddd_w&lt;BR /&gt;Sfssss_w&lt;BR /&gt;Sssss_w&lt;BR /&gt;Sfffb_w&lt;BR /&gt;Sjjjs_w&lt;BR /&gt;Sllls_w&lt;BR /&gt;Ftxxs_w&lt;BR /&gt;Dfxxs_w&lt;BR /&gt;Ltxxs_w&lt;BR /&gt;Ytxxs_w&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*So I can do something like&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select * from DATA&lt;/P&gt;&lt;P&gt;where variable in ("&lt;SPAN&gt;Sxxxf_w", "&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxa_w","&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxs_w",...)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;quit;&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;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*My try is to create a small dataset of one column which contains all the words in my macro variable.*/&amp;nbsp;&lt;/P&gt;&lt;P&gt;data filter_list;&lt;BR /&gt;input @;&lt;BR /&gt;_infile_=resolve(_infile_);&lt;BR /&gt;input vari $&amp;nbsp; @@ ;&lt;BR /&gt;datalines;&lt;BR /&gt;&amp;amp;vars&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem with this code is that SAS only reads the first 10 lines and if I increase the size of the names, sas reads even less lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477902#M286271</guid>
      <dc:creator>allen_AL</dc:creator>
      <dc:date>2018-07-13T15:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477906#M286272</link>
      <description>&lt;P&gt;What are you trying to do here? It's not clear what you're attempting and what issues you're having.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're trying to create a list of macro variables, what is your starting source? In general, it's easiest to read the data into SAS as a data set first and then convert to macro variables. See the SQL example below on how to create a macro variable list.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select quote(name) into :name_list separated by ", "
from sashelp.class;
quit;

%put &amp;amp;name_list;&lt;/CODE&gt;&lt;/PRE&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/220909"&gt;@allen_AL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reading. I have a long list with different variables in a macro variable so I can use that list to filter rows.&lt;BR /&gt;%let vars=&lt;BR /&gt;Sxxxf_w&lt;BR /&gt;Sxxxa_w&lt;BR /&gt;Sxxxs_w&lt;BR /&gt;Slxxs_w&lt;BR /&gt;rSddd_w&lt;BR /&gt;Sfssss_w&lt;BR /&gt;Sssss_w&lt;BR /&gt;Sfffb_w&lt;BR /&gt;Sjjjs_w&lt;BR /&gt;Sllls_w&lt;BR /&gt;Ftxxs_w&lt;BR /&gt;Dfxxs_w&lt;BR /&gt;Ltxxs_w&lt;BR /&gt;Ytxxs_w&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*So I can do something like&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select * from DATA&lt;/P&gt;
&lt;P&gt;where variable in ("&lt;SPAN&gt;Sxxxf_w", "&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxa_w","&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxs_w",...)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&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;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*My try:*/&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data filter_list;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187967"&gt;@input&lt;/a&gt; @;&lt;BR /&gt;_infile_=resolve(_infile_);&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187967"&gt;@input&lt;/a&gt; vari $&amp;nbsp; @@ ;&lt;BR /&gt;datalines;&lt;BR /&gt;&amp;amp;vars&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem with this code is that SAS only reads the first 10 lines and if I increase the size of the names, sas reads even less lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477906#M286272</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-13T15:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477911#M286273</link>
      <description>&lt;P&gt;/*So I can do something like&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select * from DATA&lt;/P&gt;&lt;P&gt;where variable in ("&lt;SPAN&gt;Sxxxf_w", "&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxa_w","&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxs_w",...)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;quit;&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;/P&gt;&lt;P&gt;I have a macro variable that is very long, composed of several strings. Based on that list, I need to create something like&amp;nbsp;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxf_w", "&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxa_w","&lt;/SPAN&gt;&lt;SPAN&gt;Sxxxs_w",... so I can filter a dataset using&amp;nbsp;&amp;nbsp;where variable in ("Sxxxf_w", "Sxxxa_w","Sxxxs_w",...)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477911#M286273</guid>
      <dc:creator>allen_AL</dc:creator>
      <dc:date>2018-07-13T15:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477912#M286274</link>
      <description>&lt;P&gt;A good place to start:&amp;nbsp; where did &amp;amp;VARS come from?&amp;nbsp; If it came from something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select name into : vars separated by ' '&lt;/P&gt;
&lt;P&gt;from source_table;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's the case you would better off eliminating macro language entirely.&amp;nbsp; Your final SQL could look more like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select * from DATA&lt;/P&gt;
&lt;P&gt;where variable in (select name from source_table);&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477912#M286274</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-13T15:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477913#M286275</link>
      <description>&lt;P&gt;The variable list came from word.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477913#M286275</guid>
      <dc:creator>allen_AL</dc:creator>
      <dc:date>2018-07-13T15:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477915#M286276</link>
      <description>&lt;P&gt;OK, that morphs into the approach I suggested, as long as you have Word save the document as a text file.&amp;nbsp; Then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data source_table;&lt;/P&gt;
&lt;P&gt;infile 'path to text file with list of names';&lt;/P&gt;
&lt;P&gt;length name $ 32;&lt;/P&gt;
&lt;P&gt;input name;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then proceed with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select * from DATA where&lt;/P&gt;
&lt;P&gt;variable&amp;nbsp; in (select name from source_table);&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477915#M286276</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-13T15:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477916#M286277</link>
      <description>&lt;P&gt;Paste it into the editor&lt;/P&gt;
&lt;P&gt;Read it into a data set&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use SQL to create the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data my_list;
input words $20.;
cards;
Random1
Random2
Random3
;;;;
run;

proc sql noprint;
select quote(words) into :my_list separated by ", " from my_list;
quit;

%put &amp;amp;my_list;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use the data set as indicated by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&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/220909"&gt;@allen_AL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The variable list came from word.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477916#M286277</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-13T15:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477918#M286278</link>
      <description>&lt;P&gt;Sorry for not being clear. Importing the list of variables is not a feasible or desirable thing to do. I copy and paste the list of variables. I need this macro so all the people can just open SAS, paste the list of variables they need, and click RUN.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477918#M286278</guid>
      <dc:creator>allen_AL</dc:creator>
      <dc:date>2018-07-13T15:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477919#M286279</link>
      <description>&lt;P&gt;By default DATALINES expects 80 columns of input. So your macro variable is only read for the first 80 characters. Since your example data values are each 7 characters (+1 space to separate)&lt;/P&gt;
&lt;P&gt;Please see:&lt;/P&gt;
&lt;PRE&gt;data work.filter_list;
   input @;
   length pdq $ 200;
   pdq=resolve(_infile_);
   do i=1 to countw(pdq);
      vari = scan(pdq,i);
      output;
   end;
   drop pdq i;
datalines;
&amp;amp;vars
;
run;&lt;/PRE&gt;
&lt;P&gt;as an alternate approach, though I still can't see what you are doing. If your &amp;amp;var total length is likely to be much larger then increase the length of PDQ. If any of the individual items in vars exceed 8 characters you would need to assign a length to vari in the data step long enough to handle it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your SQL might have an issue with case since you were using the IN operator the values have to match case unless you use something such as UPCASE or LOWCASE on the variable and force the list to have consistent case. Or was the question how to create a quoted list from &amp;amp;vars?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477919#M286279</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-13T15:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477920#M286280</link>
      <description>&lt;P&gt;Thanks for the reply. What I need to read the whole list of variables and paste them as a macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I basically need this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;%let vars= random1&lt;BR /&gt;random2&lt;BR /&gt;random3&lt;BR /&gt;...&lt;BR /&gt;random15&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data&lt;/SPAN&gt; my_list&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; words &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;20&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;&amp;amp;vars.&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The problem with my original code is that SAS is only readin the first 10 lines, somehow it just stops reading after that.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477920#M286280</guid>
      <dc:creator>allen_AL</dc:creator>
      <dc:date>2018-07-13T15:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477922#M286281</link>
      <description>&lt;P&gt;Sometimes we will have 40 variables of different lengths, sometimes we will have 10 variables, sometimes 20, sometimes 15, and they vary in lengths.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on your response, this task is basically impossible given the restrictions for 80?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477922#M286281</guid>
      <dc:creator>allen_AL</dc:creator>
      <dc:date>2018-07-13T15:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477924#M286282</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/220909"&gt;@allen_AL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sometimes we will have 40 variables of different lengths, sometimes we will have 10 variables, sometimes 20, sometimes 15, and they vary in lengths.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on your response, this task is basically impossible given the restrictions for 80?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, you just have to explicitly set your length and not use the default.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477924#M286282</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-13T15:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477930#M286283</link>
      <description>&lt;P&gt;A recap of what I am trying to do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have dataset A which contains several records with thousands of variable names in a the column "variables". Kind of like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variable&amp;nbsp; Value1&lt;/P&gt;&lt;P&gt;A 1&lt;BR /&gt;A 1&lt;BR /&gt;A 2&lt;/P&gt;&lt;P&gt;B 1&lt;/P&gt;&lt;P&gt;B 4&lt;/P&gt;&lt;P&gt;C 45&lt;/P&gt;&lt;P&gt;C 56&lt;/P&gt;&lt;P&gt;C 4&lt;/P&gt;&lt;P&gt;F 4&lt;/P&gt;&lt;P&gt;D 2345&lt;/P&gt;&lt;P&gt;D 22&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to filter the rows that contain the Variable "A","C", and "F".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a very simple task, the problem is that the people who will use the macro can only paste the variables they want on&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let vars=&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;C&lt;BR /&gt;F&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is the only part they can/want to modify. I need my macro to be able to read all different variables names without me having to adjust each time the length. So, if I adjust it once, will they be able to paste any kind of variables (typically the maximum will be 40 but there will be variables with a lot of characters like "super_long_variable_name_version_3".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477930#M286283</guid>
      <dc:creator>allen_AL</dc:creator>
      <dc:date>2018-07-13T15:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477932#M286284</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/220909"&gt;@allen_AL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry for not being clear. Importing the list of variables is not a feasible or desirable thing to do. I copy and paste the list of variables. I need this macro so all the people can just open SAS, paste the list of variables they need, and click RUN.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So instead of pasting into a macro variable which adds a variety of potential issues paste into a data step:&lt;/P&gt;
&lt;PRE&gt;data filter_list;
   length vari $ 32;
   input vari  ;
datalines;
Sxxxf_w
Sxxxa_w
Sxxxs_w
Slxxs_w
rSddd_w
Sfssss_w
Sssss_w
Sfffb_w
Sjjjs_w
Sllls_w
Ftxxs_w
Dfxxs_w
Ltxxs_w
Ytxxs_w
;
run;&lt;/PRE&gt;
&lt;P&gt;Since the first post implied you were likely to be attempting to match variable names of some sort then I have assigned a length of 32 as that is the current maximum for SAS variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Still have a concern with comparison and case though.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477932#M286284</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-13T15:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477935#M286285</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Several solutions since this really isn't a new question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Transform-macro-variable-to-wrap-quot-quot-around-words-within/td-p/363490" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Transform-macro-variable-to-wrap-quot-quot-around-words-within/td-p/363490&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/add-single-quotes-and-commas-to-a-list-of-words/td-p/437511" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/add-single-quotes-and-commas-to-a-list-of-words/td-p/437511&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Quote-and-Unquote-a-list/td-p/205512" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Quote-and-Unquote-a-list/td-p/205512&lt;/A&gt;&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/220909"&gt;@allen_AL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;A recap of what I am trying to do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have dataset A which contains several records with thousands of variable names in a the column "variables". Kind of like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable&amp;nbsp; Value1&lt;/P&gt;
&lt;P&gt;A 1&lt;BR /&gt;A 1&lt;BR /&gt;A 2&lt;/P&gt;
&lt;P&gt;B 1&lt;/P&gt;
&lt;P&gt;B 4&lt;/P&gt;
&lt;P&gt;C 45&lt;/P&gt;
&lt;P&gt;C 56&lt;/P&gt;
&lt;P&gt;C 4&lt;/P&gt;
&lt;P&gt;F 4&lt;/P&gt;
&lt;P&gt;D 2345&lt;/P&gt;
&lt;P&gt;D 22&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to filter the rows that contain the Variable "A","C", and "F".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a very simple task, the problem is that the people who will use the macro can only paste the variables they want on&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let vars=&lt;/P&gt;
&lt;P&gt;A&lt;/P&gt;
&lt;P&gt;C&lt;BR /&gt;F&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is the only part they can/want to modify. I need my macro to be able to read all different variables names without me having to adjust each time the length. So, if I adjust it once, will they be able to paste any kind of variables (typically the maximum will be 40 but there will be variables with a lot of characters like "super_long_variable_name_version_3".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/477935#M286285</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-13T15:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/478001#M286286</link>
      <description>&lt;P&gt;Thank you very much for your quick response.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 18:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/478001#M286286</guid>
      <dc:creator>allen_AL</dc:creator>
      <dc:date>2018-07-13T18:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable string into several parts divided by commas and quotes.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/478044#M286287</link>
      <description>&lt;P&gt;It sounds like want to convert a space delimited list of tokens to a quoted list.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First make sure you have just one space between "words". Then wrap in quotes and replace the internal spaces with quoted spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list=a b 
c d e
f

g

;
%let list=%sysfunc(compbl(&amp;amp;list));
%let qlist="%sysfunc(tranwrd(&amp;amp;list,%str( )," "))";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure why you want to add commas also, since SAS does not require them.&amp;nbsp; Put you could use "," instead of " " and then you would have commas between the quoted strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are really copying from WORD make sure that what you copy doesn't include strange non-printing characters instead of normal spaces.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 21:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-string-into-several-parts-divided-by-commas-and/m-p/478044#M286287</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-13T21:36:01Z</dc:date>
    </item>
  </channel>
</rss>

