<?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 dynamic select on datasets-code help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494044#M130115</link>
    <description>&lt;P&gt;I need to select dynamically on a data set from a list of data with libname, table name, column name for specific content. i.e.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let name=’ George’;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a select dynamically from a dataset with libname, tablename, column name and in addition a select on content in the variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can not get my code to work as I need. Do you have any suggestions? hopefully small but smart changes to the code below?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to select with&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;Data final_data_select;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;Set &amp;amp;dslist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error:&lt;/P&gt;&lt;P&gt;ERROR: The value&amp;nbsp;CONTACTS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'n is not a valid SAS name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;This is the select i want:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;Data have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;Set ccccc. Contacts(where=(name1=’George’))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hhhhh.Contacs_4(where=(name7=’George’))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hhhhh.Report_1(where=( ghhh =’George’))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Yyyy.data_content(where=( kkkkk =’George’))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;Run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My input is this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;libname&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;TABLE_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;COLUMN_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ccccc&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Contacts&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;name1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;hhhhh&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Contacs_4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;name7&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;hhhhh&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Report_1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;ghhh&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;yyyy&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;data_content&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;kkkkk&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let name=’ George’;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried something like this but it does not work almost as I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;proc sql noprint;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;select distinct&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cats(TABLE_NAME&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , '(where=( COLUMN_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ='&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,quote(trim(&amp;amp;name.))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,'))'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp; into :dslist separated by ' '&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp; from datalist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;%put &amp;amp;=dslist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;Data final_data_select;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;Set &amp;amp;dslist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Sep 2018 09:00:03 GMT</pubDate>
    <dc:creator>ANLYNG</dc:creator>
    <dc:date>2018-09-10T09:00:03Z</dc:date>
    <item>
      <title>dynamic select on datasets-code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494044#M130115</link>
      <description>&lt;P&gt;I need to select dynamically on a data set from a list of data with libname, table name, column name for specific content. i.e.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let name=’ George’;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a select dynamically from a dataset with libname, tablename, column name and in addition a select on content in the variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can not get my code to work as I need. Do you have any suggestions? hopefully small but smart changes to the code below?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to select with&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;Data final_data_select;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;Set &amp;amp;dslist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error:&lt;/P&gt;&lt;P&gt;ERROR: The value&amp;nbsp;CONTACTS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'n is not a valid SAS name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;This is the select i want:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;Data have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;Set ccccc. Contacts(where=(name1=’George’))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hhhhh.Contacs_4(where=(name7=’George’))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hhhhh.Report_1(where=( ghhh =’George’))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Yyyy.data_content(where=( kkkkk =’George’))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;Run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My input is this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;libname&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;TABLE_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;COLUMN_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ccccc&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Contacts&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;name1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;hhhhh&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Contacs_4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;name7&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;hhhhh&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Report_1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;ghhh&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;yyyy&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;data_content&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;kkkkk&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let name=’ George’;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried something like this but it does not work almost as I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;proc sql noprint;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;select distinct&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cats(TABLE_NAME&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , '(where=( COLUMN_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ='&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,quote(trim(&amp;amp;name.))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,'))'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp; into :dslist separated by ' '&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&amp;nbsp; from datalist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;%put &amp;amp;=dslist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;Data final_data_select;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;Set &amp;amp;dslist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 09:00:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494044#M130115</guid>
      <dc:creator>ANLYNG</dc:creator>
      <dc:date>2018-09-10T09:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select on datasets-code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494048#M130118</link>
      <description>&lt;P&gt;Don't put quotes in the macro variable.&amp;nbsp; That will just make your life harder.&amp;nbsp; The string after the = sign is taken exactly as is.&amp;nbsp; The code should look something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;%let name=George;&lt;/SPAN&gt;&lt;BR /&gt;data have;
  set ccccc.contacts (where=(name1="&amp;amp;name."))
       hhhhh.Contacs_4 (where=(name7="&amp;amp;name."))
       hhhhh.Report_1 (where=(ghhh="&amp;amp;name."))
       yyyy.data_content (where=(kkkkk="&amp;amp;name."));
run;&lt;/PRE&gt;
&lt;P&gt;For your second part, you can generate the code - its not a simple thing though:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let name=George;&lt;BR /&gt;data _null_;
  set yourinput end=last;
  if _n_=1 then call execute('data have set');
  call execute(cat(catx('.',libname,table_name), ' (where=(',strip(column_name),'="&amp;amp;name."))'));
  if last then call execute(';run;');
run;&lt;/PRE&gt;
&lt;P&gt;This will effectively create the first datastep, from your input dataset, rather than hardcoding in each item.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 09:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494048#M130118</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-10T09:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select on datasets-code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494065#M130125</link>
      <description>&lt;P&gt;I still get the errors like this&lt;/P&gt;&lt;P&gt;ERROR: The value&amp;nbsp;'contacts&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'n is not a valid SAS name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;and&lt;/P&gt;&lt;P&gt;ERROR: File hhhh.'Report_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'n.DATA does not exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you why ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suppose there is an ' to much ??? how to correct that one ?&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 09:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494065#M130125</guid>
      <dc:creator>ANLYNG</dc:creator>
      <dc:date>2018-09-10T09:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select on datasets-code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494068#M130128</link>
      <description>&lt;P&gt;You need to post the code and the data you are using.&amp;nbsp; Avoid using named literals - as indicated by the 'n at the end - that is only there to handle Excel and some databases which use badly formatted variable names.&amp;nbsp; Second up, as I said, you will need to strip() the values to get rid of extra whitespace.&amp;nbsp; Need to see code, and test data (form of a datastep:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;) to be able to accurately say.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 10:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494068#M130128</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-10T10:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select on datasets-code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494085#M130136</link>
      <description>&lt;P&gt;I am closer now. as i infile by text the tables, coloumn names. But can I some how keep the selected variables in the output together with data set name? as I get this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Variable&amp;nbsp;CCCC has been defined as both character and numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suppose that there is a lot of variables in the input which is defined in different ways. But I am only interested to see the content af variable and in which table it occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 11:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494085#M130136</guid>
      <dc:creator>ANLYNG</dc:creator>
      <dc:date>2018-09-10T11:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select on datasets-code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494094#M130144</link>
      <description>&lt;P&gt;This line is a mistake:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let name=’ George’;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;There is no reason to add quotes.&amp;nbsp; SAS language might need quotes, but macro language does not.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Once you fix that, you need to adjust a later line:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;,quote(trim(&amp;amp;name.))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It becomes:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;,"&amp;amp;name."&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 11:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494094#M130144</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-10T11:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select on datasets-code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494165#M130180</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/26102"&gt;@ANLYNG&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am closer now. as i infile by text the tables, coloumn names. But can I some how keep the selected variables in the output together with data set name? as I get this error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Variable&amp;nbsp;CCCC has been defined as both character and numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suppose that there is a lot of variables in the input which is defined in different ways. But I am only interested to see the content af variable and in which table it occurs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you are combining data sets with same named variables of different types then this is a likely indicator of a poorly documented process. If you expect all same named variables to have the same format then you should verify that in a step prior to attempting to combine the data else it will fail. Every time. If you only want specific variables then add Keep= dataset option to restrict the data to those variables.&lt;/P&gt;
&lt;P&gt;But having one variable which as been defined as both character and numeric makes it likely that you have others. The single most common cause of this is relying too heavily on Proc Import or an import wizard task for multiple files. The procedure has to guess each time a file of the same layout is read and will often make different guesses because it is only examining a few rows of data.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 15:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494165#M130180</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-10T15:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select on datasets-code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494252#M130214</link>
      <description>&lt;P&gt;i got it to work after i elimininated the dataset with both numeric and char variable. I get a lot of variables - do you know how to keep only the variable_name and table_name for the dataset with contents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 18:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494252#M130214</guid>
      <dc:creator>ANLYNG</dc:creator>
      <dc:date>2018-09-10T18:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select on datasets-code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494338#M130244</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/26102"&gt;@ANLYNG&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i got it to work after i elimininated the dataset with both numeric and char variable. I get a lot of variables - do you know how to keep only the variable_name and table_name for the dataset with contents.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Keep is the general instruction to keep a specific list of variables. I am not quite sure what you mean by&amp;nbsp; "keep only table_name" if it is not a variable in the data sets in question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set dataset1 (keep=variablename1 variablename2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataset2 (keep=variablename1 variablename2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your variables do not have the same length you will get a warning about different lengths assigned and possible truncation of data.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 23:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamic-select-on-datasets-code-help/m-p/494338#M130244</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-10T23:15:22Z</dc:date>
    </item>
  </channel>
</rss>

