<?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: How to select variables from dataset that have common suffix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245791#M45893</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for trying to help&lt;/P&gt;&lt;P&gt;I run the code you provided. Please see below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select distinct name
	into :names 
	from dictionary.columns
	where lowcase(memname)='portfolio' 
		and name like 'Return%';

proc sql outobs=20;
	select *
	from portfolio (keep=&amp;amp;names);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then I got error message. Please see below:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1599iE20E72402A82DE0A/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jan 2016 02:47:48 GMT</pubDate>
    <dc:creator>BingL</dc:creator>
    <dc:date>2016-01-25T02:47:48Z</dc:date>
    <item>
      <title>How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245763#M45882</link>
      <description>&lt;P&gt;Hello to whomever can help me out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a data like following&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1597i7F1621863C886C94/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;I want to select those variables that have _return suffix.&lt;/P&gt;&lt;P&gt;Try to run the following code:&lt;/P&gt;&lt;PRE&gt;proc sql outobs=25;
	select *
	from portfolio (keep=:return);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but it does not work because the name is not valid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 00:04:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245763#M45882</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-25T00:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245770#M45884</link>
      <description>&lt;P&gt;There is no shortcut way to reference variables with a common suffix, only a common prefix.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 00:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245770#M45884</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-25T00:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245771#M45885</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 00:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245771#M45885</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-25T00:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245775#M45889</link>
      <description>&lt;P&gt;Change your naming structure to RETURN_VAR would make this possible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, look into Variable Labels vs Variable Names as you can use the labels to make your reporting more versatile and then have more flexibility in your naming conventions.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 00:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245775#M45889</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-25T00:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245776#M45890</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did that. it works&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 01:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245776#M45890</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-25T01:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245778#M45891</link>
      <description>&lt;P&gt;you may try it by selecting the list of variable names ending with common suffix into a macro variable and then calling the macro variable will keep only those variables. &lt;BR /&gt;&lt;BR /&gt;Like &lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select distinct name into: names from dictionary.columns where lowcase(memname)='portfolio' and name like 'RETURN%';&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;proc sql outobs=25;&lt;BR /&gt; select *&lt;BR /&gt; from portfolio (keep=&amp;amp;names);&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 01:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245778#M45891</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-01-25T01:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245791#M45893</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for trying to help&lt;/P&gt;&lt;P&gt;I run the code you provided. Please see below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select distinct name
	into :names 
	from dictionary.columns
	where lowcase(memname)='portfolio' 
		and name like 'Return%';

proc sql outobs=20;
	select *
	from portfolio (keep=&amp;amp;names);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then I got error message. Please see below:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1599iE20E72402A82DE0A/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 02:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245791#M45893</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-25T02:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245795#M45894</link>
      <description>Thank you for trying my code, could you please change the case of the text(return) in the where condition &lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;	select distinct name&lt;BR /&gt;	into :names &lt;BR /&gt;	from dictionary.columns&lt;BR /&gt;	where lowcase(memname)='portfolio' &lt;BR /&gt;		and upcase(name) like '%RETURN';&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jan 2016 03:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245795#M45894</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-01-25T03:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245800#M45895</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for trying to help&lt;/P&gt;&lt;P&gt;now your code has no error, but the result is &amp;nbsp;not very ideal. Please see the screenshot. I want all the variables with _return suffix to be selected, but your program only select one varaible in the PROC SQL process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1601i8190840D15278385/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 03:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245800#M45895</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-25T03:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245802#M45896</link>
      <description>&lt;P&gt;You should be able to help debug this if you're using these methodologies - I think three of your recent questions are along the same lines here - using the SASHELP tables to generate a dynamic variable list.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is why the SEPARATED BY is included, otherwise SQL will only return a single value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 03:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245802#M45896</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-25T03:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245803#M45897</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;You are right SEPERATED BY is the key to his code.&lt;/P&gt;&lt;P&gt;now it all worked out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all for your wonderful helps and effort.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 03:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245803#M45897</guid>
      <dc:creator>BingL</dc:creator>
      <dc:date>2016-01-25T03:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to select variables from dataset that have common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245804#M45898</link>
      <description>I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; and you, i missed the separated by. &lt;BR /&gt;&lt;BR /&gt;Thanks for checking back</description>
      <pubDate>Mon, 25 Jan 2016 03:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-variables-from-dataset-that-have-common-suffix/m-p/245804#M45898</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-01-25T03:47:46Z</dc:date>
    </item>
  </channel>
</rss>

