<?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: Better way to create indicator variable in PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Better-way-to-create-indicator-variable-in-PROC-SQL/m-p/68750#M14895</link>
    <description>I think your code is good enough.If you want more brief.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data class;&lt;BR /&gt;
 set sashelp.class end=last; output;&lt;BR /&gt;
 if last then do;&lt;BR /&gt;
              name='Peter';sex=' '; output;&lt;BR /&gt;
              end;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 create table temp as&lt;BR /&gt;
  select a.*,not missing(a.sex) as ind&lt;BR /&gt;
   from class as a left join class as b on a.sex=b.sex;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Tue, 24 May 2011 01:09:48 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-05-24T01:09:48Z</dc:date>
    <item>
      <title>Better way to create indicator variable in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Better-way-to-create-indicator-variable-in-PROC-SQL/m-p/68749#M14894</link>
      <description>I wonder if there is a better way to create a indicator variable as shown in the following sql statement:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  create table ds3 as&lt;BR /&gt;
  select a.*,&lt;BR /&gt;
         case&lt;BR /&gt;
           when b.id = '' then 0&lt;BR /&gt;
           else 1&lt;BR /&gt;
         end as ind&lt;BR /&gt;
  from ds1 a left join ds2 b&lt;BR /&gt;
  on a.id = b.id&lt;BR /&gt;
; quit;</description>
      <pubDate>Mon, 23 May 2011 23:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Better-way-to-create-indicator-variable-in-PROC-SQL/m-p/68749#M14894</guid>
      <dc:creator>MarcTC</dc:creator>
      <dc:date>2011-05-23T23:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Better way to create indicator variable in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Better-way-to-create-indicator-variable-in-PROC-SQL/m-p/68750#M14895</link>
      <description>I think your code is good enough.If you want more brief.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data class;&lt;BR /&gt;
 set sashelp.class end=last; output;&lt;BR /&gt;
 if last then do;&lt;BR /&gt;
              name='Peter';sex=' '; output;&lt;BR /&gt;
              end;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 create table temp as&lt;BR /&gt;
  select a.*,not missing(a.sex) as ind&lt;BR /&gt;
   from class as a left join class as b on a.sex=b.sex;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 24 May 2011 01:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Better-way-to-create-indicator-variable-in-PROC-SQL/m-p/68750#M14895</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-24T01:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Better way to create indicator variable in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Better-way-to-create-indicator-variable-in-PROC-SQL/m-p/68751#M14896</link>
      <description>You can make your code a touch more efficient with a little boolean logic:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table ds3 as&lt;BR /&gt;
  select a.*&lt;BR /&gt;
      , b.id NE '' as ind&lt;BR /&gt;
   from ds1 a left join ds2 b&lt;BR /&gt;
      on a.id = b.id&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: SASJedi

Message was edited by: SASJedi</description>
      <pubDate>Tue, 24 May 2011 02:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Better-way-to-create-indicator-variable-in-PROC-SQL/m-p/68751#M14896</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2011-05-24T02:24:49Z</dc:date>
    </item>
  </channel>
</rss>

