<?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 extract a specified values from the data with a common value? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759830#M240193</link>
    <description>&lt;P&gt;OK.&amp;nbsp; No problem.&amp;nbsp; How about the below code?&amp;nbsp; Same (identical) result but using a WHERE clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	Have;
	INPUT	CODE	$;
DATALINES;
C50.012
Z180
H05.23
C90.00
I90
C50.011
C50.111
284.19
K59.09
C50.112
C50.119
Z89.09
C50.211
C50.212
C50.311
;
RUN;

/*DATA	Want;*/
/*	SET	Have;*/
/*	IF	INDEX(Code, 'C50');*/
/*RUN;*/

PROC	SQL;
	CREATE	TABLE	Want	AS
		SELECT	Code
			FROM	Have
				WHERE	INDEX(Code, 'C50')
				;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 05 Aug 2021 22:50:16 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2021-08-05T22:50:16Z</dc:date>
    <item>
      <title>How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759824#M240189</link>
      <description>&lt;P&gt;I have a variable which has values like below;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;C50.012&lt;/P&gt;
&lt;P&gt;Z180&lt;/P&gt;
&lt;P&gt;H05.23&lt;/P&gt;
&lt;P&gt;C90.00&lt;/P&gt;
&lt;P&gt;I90&lt;/P&gt;
&lt;P&gt;C50.011&lt;/P&gt;
&lt;P&gt;C50.111&lt;/P&gt;
&lt;P&gt;284.19&lt;/P&gt;
&lt;P&gt;K59.09&lt;/P&gt;
&lt;P&gt;C50.112&lt;/P&gt;
&lt;P&gt;C50.119&lt;/P&gt;
&lt;P&gt;Z89.09&lt;/P&gt;
&lt;P&gt;C50.211&lt;/P&gt;
&lt;P&gt;C50.212&lt;/P&gt;
&lt;P&gt;C50.311&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i extract all the values that start with C50 from that code variable ?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 22:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759824#M240189</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-08-05T22:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759826#M240191</link>
      <description>&lt;P&gt;Have you tried using the INDEX() function?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like the below program which yields:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1628203632494.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62313i2D57819A7B18DD21/image-size/large?v=v2&amp;amp;px=999" role="button" title="jimbarbour_0-1628203632494.png" alt="jimbarbour_0-1628203632494.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	Have;
	INPUT	CODE	$;
DATALINES;
C50.012
Z180
H05.23
C90.00
I90
C50.011
C50.111
284.19
K59.09
C50.112
C50.119
Z89.09
C50.211
C50.212
C50.311
;
RUN;

DATA	Want;
	SET	Have;
	IF	INDEX(Code, 'C50');
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Aug 2021 22:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759826#M240191</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-08-05T22:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759827#M240192</link>
      <description>I am trying to filter the data in the WHERE condition statement.</description>
      <pubDate>Thu, 05 Aug 2021 22:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759827#M240192</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-08-05T22:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759830#M240193</link>
      <description>&lt;P&gt;OK.&amp;nbsp; No problem.&amp;nbsp; How about the below code?&amp;nbsp; Same (identical) result but using a WHERE clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	Have;
	INPUT	CODE	$;
DATALINES;
C50.012
Z180
H05.23
C90.00
I90
C50.011
C50.111
284.19
K59.09
C50.112
C50.119
Z89.09
C50.211
C50.212
C50.311
;
RUN;

/*DATA	Want;*/
/*	SET	Have;*/
/*	IF	INDEX(Code, 'C50');*/
/*RUN;*/

PROC	SQL;
	CREATE	TABLE	Want	AS
		SELECT	Code
			FROM	Have
				WHERE	INDEX(Code, 'C50')
				;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Aug 2021 22:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759830#M240193</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-08-05T22:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759831#M240194</link>
      <description>Can we give multiple values here? For eg, I also want to filter values starting with "H" "C56" etc., ?</description>
      <pubDate>Thu, 05 Aug 2021 22:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759831#M240194</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-08-05T22:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759833#M240196</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input   CODE :$10.;
  cards;
C50.012

Z180

H05.23

C90.00

I90

C50.011

C50.111

284.19

K59.09

C50.112

C50.119

Z89.09

C50.211

C50.212

C50.311
;

data want;
  set have;
  where scan(code,1,'.')='C50';
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Aug 2021 22:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759833#M240196</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-08-05T22:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759835#M240197</link>
      <description>&lt;P&gt;Yes.&amp;nbsp; Just use an OR to add additional uses of the INDEX function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC	SQL;
	CREATE	TABLE	Want	AS
		SELECT	Code
			FROM	Have
				WHERE	INDEX(Code, 'C50')
					OR	INDEX(Code, 'C56')
					OR	INDEX(Code, 'H')
				;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 22:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759835#M240197</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-08-05T22:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759836#M240198</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE CODE IN: ("C50", "H", "Z");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Use the colon operator and IN.&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/294544"&gt;@RAVI2000&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a variable which has values like below;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;C50.012&lt;/P&gt;
&lt;P&gt;Z180&lt;/P&gt;
&lt;P&gt;H05.23&lt;/P&gt;
&lt;P&gt;C90.00&lt;/P&gt;
&lt;P&gt;I90&lt;/P&gt;
&lt;P&gt;C50.011&lt;/P&gt;
&lt;P&gt;C50.111&lt;/P&gt;
&lt;P&gt;284.19&lt;/P&gt;
&lt;P&gt;K59.09&lt;/P&gt;
&lt;P&gt;C50.112&lt;/P&gt;
&lt;P&gt;C50.119&lt;/P&gt;
&lt;P&gt;Z89.09&lt;/P&gt;
&lt;P&gt;C50.211&lt;/P&gt;
&lt;P&gt;C50.212&lt;/P&gt;
&lt;P&gt;C50.311&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i extract all the values that start with C50 from that code variable ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 22:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759836#M240198</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-08-05T22:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759837#M240199</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294544"&gt;@RAVI2000&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take a look at what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;is suggesting.&amp;nbsp; That's an improvement on my multiple values example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding it all together:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC	SQL;
	CREATE	TABLE	Want	AS
		SELECT	Code
			FROM	Have
				WHERE	Code  IN:  ('C50', 'C56', 'H')
				;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 23:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759837#M240199</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-08-05T23:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759850#M240203</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't get the colon operator to work with IN in my SQL.&amp;nbsp; Doing a quick Google, I found&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings09/056-2009.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings09/056-2009.pdf&lt;/A&gt;&amp;nbsp;which I have excerpted, below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1628208424390.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62315i53FB527BBCFB77B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="jimbarbour_0-1628208424390.png" alt="jimbarbour_0-1628208424390.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Apparently no such luck with SQL.&amp;nbsp; Any other suggestions or does one just have to list the conditions one by one as in my first SQL example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Fri, 06 Aug 2021 00:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759850#M240203</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-08-06T00:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759852#M240205</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37107"&gt;@jimbarbour&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't get the colon operator to work with IN in my SQL.&amp;nbsp; Doing a quick Google, I found&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings09/056-2009.pdf" target="_blank" rel="noopener"&gt;https://support.sas.com/resources/papers/proceedings09/056-2009.pdf&lt;/A&gt;&amp;nbsp;which I have excerpted, below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1628208424390.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62315i53FB527BBCFB77B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="jimbarbour_0-1628208424390.png" alt="jimbarbour_0-1628208424390.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Apparently no such luck with SQL.&amp;nbsp; Any other suggestions or does one just have to list the conditions one by one as in my first SQL example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If it isn't in ANSI SQL SAS is unlikely to implement it Proc SQL.&lt;/P&gt;
&lt;P&gt;I think about the only exception to that may be some of the functions, but base syntax like comparison operators not in Proc SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any real reason not to use a Data step instead of Proc SQL?&lt;/P&gt;
&lt;P&gt;Perhaps another table with the distinct "before the decimal" code values wanted from the data and then join on that table with something like a.distinctcode = scan(fulldata.code,1,'.')&lt;/P&gt;</description>
      <pubDate>Fri, 06 Aug 2021 00:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759852#M240205</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-06T00:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759865#M240209</link>
      <description>like% function would work with it.</description>
      <pubDate>Fri, 06 Aug 2021 04:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759865#M240209</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-08-06T04:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a specified values from the data with a common value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759923#M240248</link>
      <description>&lt;BR /&gt;data want;&lt;BR /&gt;  set have;&lt;BR /&gt;  if code=:'C50';&lt;BR /&gt; run;</description>
      <pubDate>Fri, 06 Aug 2021 12:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-specified-values-from-the-data-with-a-common/m-p/759923#M240248</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-06T12:38:36Z</dc:date>
    </item>
  </channel>
</rss>

