<?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 SAS drops variable on its own in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450608#M113466</link>
    <description>&lt;P&gt;Please run this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input client code $;
cards;
1 A
1 B
2 A
3 A
3 C
3 D
4 A
5 A
5 B
;
run;

data int;
set have (where=(code ne 'A')) ;
val = 1;
run;

proc transpose
  data=int
  out=codes (drop=_name_)
;
by client;
id code;
var val;
run;

data want;
merge
  have (
    in=a
    where=(code = 'A')
  )
  codes
;
by client;
if a;
A = 1;
drop code;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get this result:&lt;/P&gt;
&lt;PRE&gt;client    B    C    D

   1      1    .    .
   2      .    .    .
   3      .    1    1
   4      .    .    .
   5      1    .    .
&lt;/PRE&gt;
&lt;P&gt;Why is variable A missing from the dataset want?&lt;/P&gt;
&lt;P&gt;Even the log does not have it:&lt;/P&gt;
&lt;PRE&gt;52         
53         data want;
54         merge
55           have (
56             in=a
57             where=(code = 'A')
58           )
59           codes
60         ;
61         by client;
62         if a;
63         A = 1;
64         drop code;
65         run;

NOTE: There were 5 observations read from the data set WORK.HAVE.
      WHERE code='A';
NOTE: There were 3 observations read from the data set WORK.CODES.
NOTE: The data set WORK.WANT has 5 observations and 4 variables.
&lt;/PRE&gt;
&lt;P&gt;This happens on SAS 9.4M5 on AIX 7.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please tell me I'm not going crazy!&lt;/P&gt;</description>
    <pubDate>Tue, 03 Apr 2018 13:01:37 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-04-03T13:01:37Z</dc:date>
    <item>
      <title>SAS drops variable on its own</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450608#M113466</link>
      <description>&lt;P&gt;Please run this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input client code $;
cards;
1 A
1 B
2 A
3 A
3 C
3 D
4 A
5 A
5 B
;
run;

data int;
set have (where=(code ne 'A')) ;
val = 1;
run;

proc transpose
  data=int
  out=codes (drop=_name_)
;
by client;
id code;
var val;
run;

data want;
merge
  have (
    in=a
    where=(code = 'A')
  )
  codes
;
by client;
if a;
A = 1;
drop code;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get this result:&lt;/P&gt;
&lt;PRE&gt;client    B    C    D

   1      1    .    .
   2      .    .    .
   3      .    1    1
   4      .    .    .
   5      1    .    .
&lt;/PRE&gt;
&lt;P&gt;Why is variable A missing from the dataset want?&lt;/P&gt;
&lt;P&gt;Even the log does not have it:&lt;/P&gt;
&lt;PRE&gt;52         
53         data want;
54         merge
55           have (
56             in=a
57             where=(code = 'A')
58           )
59           codes
60         ;
61         by client;
62         if a;
63         A = 1;
64         drop code;
65         run;

NOTE: There were 5 observations read from the data set WORK.HAVE.
      WHERE code='A';
NOTE: There were 3 observations read from the data set WORK.CODES.
NOTE: The data set WORK.WANT has 5 observations and 4 variables.
&lt;/PRE&gt;
&lt;P&gt;This happens on SAS 9.4M5 on AIX 7.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please tell me I'm not going crazy!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 13:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450608#M113466</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-03T13:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS drops variable on its own</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450611#M113468</link>
      <description>&lt;P&gt;Well, in= variables get dropped automatically.&amp;nbsp; So even if you change the value of an in= variable, that won't be sufficient to keep it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's possible that this is just an oversight that you were reusing the variable.&amp;nbsp; Maybe this combination will strike you as unusual:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if a;&lt;/P&gt;
&lt;P&gt;A=1;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 13:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450611#M113468</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-03T13:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS drops variable on its own</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450617#M113471</link>
      <description>&lt;P&gt;Of course it was an oversight on my part. Reusing the simple name A was the reason.&lt;/P&gt;
&lt;P&gt;This time I really needed another pair of eyeballs.&lt;/P&gt;
&lt;P&gt;Thanks very much, I'm still sane.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 13:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450617#M113471</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-03T13:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS drops variable on its own</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450624#M113475</link>
      <description>&lt;P&gt;I always try to use variable names that start with IN for the IN= dataset option. So IN=in1 or IN=in_master instead of things like&amp;nbsp;IN=A.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is still possible to have name conflicts, but at least then the reason might be easier to spot.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 13:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450624#M113475</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-03T13:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS drops variable on its own</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450626#M113476</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I always try to use variable names that start with IN for the IN= dataset option. So IN=in1 or IN=in_master instead of things like&amp;nbsp;IN=A.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is still possible to have name conflicts, but at least then the reason might be easier to spot.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;lt;grin&amp;gt;&lt;/P&gt;
&lt;P&gt;I'm used to use simple names like a,b,c for my in= variables because in a production environment there &lt;EM&gt;never&lt;/EM&gt; are such names in datasets. But with simple example code ...&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 13:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-variable-on-its-own/m-p/450626#M113476</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-03T13:31:39Z</dc:date>
    </item>
  </channel>
</rss>

