<?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 do I keep some character values for a certain variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283619#M57771</link>
    <description>&lt;P&gt;Mostly it makes sense.&amp;nbsp; This statement would apply:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if sym_suffix in ('A', ' ') then delete;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the timing isn't clear.&amp;nbsp; What is the "time" data step?&amp;nbsp; Should these observations be deleted before computing last.time2 or after?&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jul 2016 20:53:47 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-07-11T20:53:47Z</dc:date>
    <item>
      <title>How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283595#M57758</link>
      <description>&lt;P&gt;I am using a very large database and want to keep some of the variables within the database.&amp;nbsp; Further, I want to only keep certain values of chosen variables within the database.&amp;nbsp; I've been trying to format this properly and have not been successful. The program below runs just fine except when I try to limit which values in sym_suffix that I keep (this is the data line with the asterisk).&amp;nbsp; sym_suffix is a character variable that could be up to ten characters. Any help you can provide will be greatly appreciated.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data vtemp /view=vtemp;&lt;BR /&gt;&amp;nbsp; set taqmsec.ctm_20150707 (keep= sym_root&amp;nbsp; sym_suffix&amp;nbsp; Time_m TR_scond&amp;nbsp; );&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;where sym_root in('ABT','HON','AA','AEP');&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;where also time_m between '09:30:00.000't and '10:00:00.000't;&lt;BR /&gt;&amp;nbsp; TIME2=time_m-mod(time_m,60);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;data no_ctm_20150707;&lt;BR /&gt;&amp;nbsp; set vtemp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;by sym_root&amp;nbsp; sym_suffix&amp;nbsp; time2;&lt;BR /&gt;&amp;nbsp; if last.time2;&lt;BR /&gt;*&amp;nbsp; if sym_suffix = 'A' or '.'&amp;nbsp; then keep;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 19:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283595#M57758</guid>
      <dc:creator>kbl</dc:creator>
      <dc:date>2016-07-11T19:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283602#M57759</link>
      <description>You can't use KEEP/DROP conditionally. &lt;BR /&gt;What is the condition? Do you want to keep the column/variable if any observation/row have the values A or missing? If yes, there have been several threads recently discussing this topic - do a serch.&lt;BR /&gt;&lt;BR /&gt;Or are you confusing KEEP with filtering observations?  If this is the case use your condition in a WHERE statement instead.</description>
      <pubDate>Mon, 11 Jul 2016 19:57:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283602#M57759</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-07-11T19:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283612#M57766</link>
      <description>&lt;P&gt;Technically,&amp;nbsp; you could just shorten your statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if sym_suffix in ('A', '.');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even though you described your objective, it's tough to tell if that will do what you want.&amp;nbsp; These are the questions I would start with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, does your variable SYM_SUFFIX really take on a value of "."?&amp;nbsp; Or are you just looking to delete blank values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, do you understand that you are subsetting observations only, and not subsetting variables (except for KEEP= on the SET statement)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There could easily be follow-up questions, but that's the starting point.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 20:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283612#M57766</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-11T20:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283616#M57768</link>
      <description>&lt;P&gt;Thanks for your reply, especially since I hadn't tried the where statement.&amp;nbsp; I added it as indicated below.&amp;nbsp; Note:&amp;nbsp; what I want is for the sym_suffix variable to be either an A or a blank space, and I want these to be sorted prior to the time adjustment.&amp;nbsp; When I ran it, I only generated sym_suffix variables with an A.&amp;nbsp; When I changed the order to where also sym_suffix = '&amp;nbsp; ' or 'A', I ended up with all of the sym_suffix variables listed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data vtemp /view=vtemp;&lt;BR /&gt;&amp;nbsp; set taqmsec.ctm_20150707 (keep= sym_root&amp;nbsp; sym_suffix&amp;nbsp; Time_m TR_scond&amp;nbsp; );&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;where sym_root in('ABT','HON','AA','AEP');&lt;BR /&gt;&lt;BR /&gt;where also sym_suffix=&amp;nbsp;&amp;nbsp; 'A' or ' '&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;where also time_m between '09:30:00.000't and '10:00:00.000't;&lt;BR /&gt;&amp;nbsp; TIME2=time_m-mod(time_m,60);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;data no_ctm_20150707;&lt;BR /&gt;&amp;nbsp; set vtemp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;by sym_root&amp;nbsp; sym_suffix&amp;nbsp; time2;&lt;BR /&gt;&amp;nbsp; if last.time2;&lt;BR /&gt;*&amp;nbsp; if sym_suffix = 'A' or '.'&amp;nbsp; then keep;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 20:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283616#M57768</guid>
      <dc:creator>kbl</dc:creator>
      <dc:date>2016-07-11T20:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283618#M57770</link>
      <description>&lt;P&gt;Thank you for responding.&amp;nbsp; Of my 11 million rows of data, I want the lines of data or observations where sym_suffix equals the letter A or a blank space.&amp;nbsp; If sym_suffix does not equat A or a blank, then I want that observation row and all of the variables in that row deleted.&amp;nbsp; And I want this deletion completed prior to the time data step.&amp;nbsp; Does that make sense?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 20:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283618#M57770</guid>
      <dc:creator>kbl</dc:creator>
      <dc:date>2016-07-11T20:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283619#M57771</link>
      <description>&lt;P&gt;Mostly it makes sense.&amp;nbsp; This statement would apply:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if sym_suffix in ('A', ' ') then delete;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the timing isn't clear.&amp;nbsp; What is the "time" data step?&amp;nbsp; Should these observations be deleted before computing last.time2 or after?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 20:53:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283619#M57771</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-11T20:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283622#M57774</link>
      <description>I want to keep the observations that have sym_suffix of A or blank. I tried substituting keep for "delete" in your statement, but I got a message it's used out of order. Here's where I placed the statement (I also tried placing the keep statement right after the set statement, and that didn't work either). Thanks for your help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data vtemp /view=vtemp;&lt;BR /&gt;set taqmsec.ctm_20150707 (keep= sym_root sym_suffix Time_m TR_scond );&lt;BR /&gt;&lt;BR /&gt;where sym_root in('ABT','HON','AA','AEP');&lt;BR /&gt;&lt;BR /&gt;if sym_suffix in ('A', ' ') then keep;&lt;BR /&gt;&lt;BR /&gt;where also time_m between '09:30:00.000't and '10:00:00.000't;&lt;BR /&gt;TIME2=time_m-mod(time_m,60);&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data no_ctm_20150707;&lt;BR /&gt;set vtemp;&lt;BR /&gt;&lt;BR /&gt;by sym_root sym_suffix time2;&lt;BR /&gt;if last.time2;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Jul 2016 21:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283622#M57774</guid>
      <dc:creator>kbl</dc:creator>
      <dc:date>2016-07-11T21:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283624#M57776</link>
      <description>&lt;P&gt;Try getting rid of "then keep":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if sym_suffix in ('A', ' ');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That might do it.&amp;nbsp; But even if it doesn't, you'll still be closer to the final result you need.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 21:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283624#M57776</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-11T21:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283632#M57784</link>
      <description>As far as I can tell you want to subset your data, and for that WHERE is the most efficient method.</description>
      <pubDate>Mon, 11 Jul 2016 21:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283632#M57784</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-07-11T21:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I keep some character values for a certain variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283633#M57785</link>
      <description>Thanks so much for all of your help; the program is doing precisely what I want now.</description>
      <pubDate>Mon, 11 Jul 2016 21:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-keep-some-character-values-for-a-certain-variable/m-p/283633#M57785</guid>
      <dc:creator>kbl</dc:creator>
      <dc:date>2016-07-11T21:34:03Z</dc:date>
    </item>
  </channel>
</rss>

