<?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: Drop / delete certain attributes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/372215#M275954</link>
    <description>&lt;P&gt;The SET statement is an EXECUTED statement, not just something that is used during the compilation of the data step. &amp;nbsp;Where you place it in your program makes a difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are creating the new variable COUNTY based on the values of DIVISION_COUNTY_NME from the previous observation.&lt;/P&gt;
&lt;P&gt;Try this little program.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   length new_name name $30 ;
   new_name = name ;
   set sashelp.class ;
run;
proc print;
  var name new_name ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 30 Jun 2017 15:21:23 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-06-30T15:21:23Z</dc:date>
    <item>
      <title>Drop / delete certain attributes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/371972#M275951</link>
      <description>&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; line-height: 150%; font-family: 'Helvetica',sans-serif; font-size: 10.5pt;"&gt;Hi I simply want to keep only data with centain qualities.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; line-height: 150%; font-family: 'Helvetica',sans-serif; font-size: 10.5pt;"&gt;&amp;nbsp;Can somebody spot the mistake?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; line-height: 150%; font-family: 'Helvetica',sans-serif; font-size: 10.5pt;"&gt;I don't understand why my code gives me a totally wrong output.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;Data Kea.Trails1b(COMPRESS = YES REUSE = YES);  
length DIVISION_COUNTY_NME $30; 
format DIVISION_COUNTY_NME $30.; 
If DIVISION_COUNTY_NME in ('Denver','Douglas','Arapahoe', 'Jefferson', 'Adams', 'Bromfield', 'Elbert', 'Park', 
'Clear Creek','Gilpin', 'Larimer' )
THEN COUNTY = "yes" ;ELSE COUNTY = "no";
Set  Kea.Trails1a;
run;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; line-height: 150%; font-family: 'Helvetica',sans-serif; font-size: 10.5pt;"&gt;I read it is easier to introduce a new variable and then delete the records with that specific variable pattern.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; line-height: 150%; font-family: 'Helvetica',sans-serif; font-size: 10.5pt;"&gt;So here I want to keep records with the Counties: &amp;nbsp;'Denver','Douglas','Arapahoe', 'Jefferson', 'Adams', 'Bromfield', 'Elbert', 'Park',&lt;BR /&gt;'Clear Creek','Gilpin', 'Larimer' they shoud all become COUNTY = "yes" ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; line-height: 150%; font-family: 'Helvetica',sans-serif; font-size: 10.5pt;"&gt;&lt;IMG title="1.JPG" alt="1.JPG" src="https://communities.sas.com/t5/image/serverpage/image-id/10041iF266C7E78A01BFFB/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="margin: 0px; color: #333333; line-height: 150%; font-family: 'Helvetica',sans-serif; font-size: 10.5pt;"&gt;Why is this&amp;nbsp;not happening?? Please see screenshot below.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 02:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/371972#M275951</guid>
      <dc:creator>AnnaNZ</dc:creator>
      <dc:date>2017-06-30T02:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Drop / delete certain attributes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/371975#M275952</link>
      <description>&lt;P&gt;try trim, see whether it will bring any change&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;If trim(DIVISION_COUNTY_NME) in ('Denver','Douglas','Arapahoe', 'Jefferson', 'Adams', 'Bromfield', 'Elbert', 'Park', 
'Clear Creek','Gilpin', 'Larimer' )&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 02:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/371975#M275952</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-30T02:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Drop / delete certain attributes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/371977#M275953</link>
      <description>&lt;P&gt;Order of operations - move your SET statement up to either right after your DATA statement or after the LENGTH/FORMAT statements if you need to explicitly define those before you read in the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Kea.Trails1b(COMPRESS = YES REUSE = YES);
  
Set  Kea.Trails1a;

length DIVISION_COUNTY_NME $30; 
format DIVISION_COUNTY_NME $30.; 

If DIVISION_COUNTY_NME in ('Denver','Douglas','Arapahoe', 'Jefferson', 'Adams', 'Bromfield', 'Elbert', 'Park', 
'Clear Creek','Gilpin', 'Larimer' )
THEN COUNTY = "yes" ;
ELSE COUNTY = "no";

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 02:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/371977#M275953</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-30T02:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Drop / delete certain attributes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/372215#M275954</link>
      <description>&lt;P&gt;The SET statement is an EXECUTED statement, not just something that is used during the compilation of the data step. &amp;nbsp;Where you place it in your program makes a difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are creating the new variable COUNTY based on the values of DIVISION_COUNTY_NME from the previous observation.&lt;/P&gt;
&lt;P&gt;Try this little program.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   length new_name name $30 ;
   new_name = name ;
   set sashelp.class ;
run;
proc print;
  var name new_name ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jun 2017 15:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/372215#M275954</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-30T15:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Drop / delete certain attributes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/372227#M275955</link>
      <description>&lt;P&gt;Please see this example code for what was happening based on similar logic. The second data step shows the value that was compared and may help you understand why the second Adams was marked correctly.&lt;/P&gt;
&lt;PRE&gt;data example;
   input letter $;
datalines;
a
b
c
d
e
f
;
run;

data example2;
   if letter in ('a','c') then found='yes';
   lv = letter;
   set example;
   label lv='Actual value of letter compared';
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-delete-certain-attributes/m-p/372227#M275955</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-30T16:03:25Z</dc:date>
    </item>
  </channel>
</rss>

