<?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: what procedure for saving id exist in all year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253849#M268838</link>
    <description>&lt;P&gt;I'm not quite sure of your desired output. You repeatedly say "save" but if an ID failys the "every month" test it could pass the "every year" test.&lt;/P&gt;
&lt;P&gt;So this looks like you want three separate data sets, is that correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What will you do with the output if so?&lt;/P&gt;</description>
    <pubDate>Wed, 02 Mar 2016 15:47:16 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-03-02T15:47:16Z</dc:date>
    <item>
      <title>what procedure for saving id exist in all year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253806#M268832</link>
      <description>&lt;P&gt;I have a dataset with variable: year quarter month ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;year is from 1990 to 2000&lt;/P&gt;&lt;P&gt;quarter is 1, 2, 3, 4&lt;/P&gt;&lt;P&gt;month is &amp;nbsp;1,2,3,,,,,12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) only save ID that appears&amp;nbsp;in every year (it should have&amp;nbsp;&lt;U&gt;at leat&amp;nbsp;&lt;/U&gt;&lt;U&gt;&lt;STRONG&gt;two&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;U&gt;observation every&lt;/U&gt; &lt;U&gt;year(that is, as long as it has observations for any two months in each&lt;/U&gt;&lt;U&gt; year&lt;/U&gt;&lt;U&gt;, then it will be saved)&lt;/U&gt;,&amp;nbsp;from 1990 to 2000);&lt;/P&gt;&lt;P&gt;With this condition, would expect to save obs for:&amp;nbsp; aa, bb, cc, ee&lt;/P&gt;&lt;P&gt;2)&amp;nbsp;only save ID that appears&amp;nbsp;in every quarter (it should&amp;nbsp;have&amp;nbsp;&lt;U&gt;at leat&amp;nbsp;&lt;/U&gt;&lt;U&gt;&lt;STRONG&gt;one&lt;/STRONG&gt;&lt;/U&gt;&lt;U&gt;&amp;nbsp;observation&lt;/U&gt;&amp;nbsp;in each&amp;nbsp;quarter within each year, from 1990 Q1 to 2000 Q4);&lt;/P&gt;&lt;P&gt;With this condition, would expect to save obs for: aa, bb, ee&lt;/P&gt;&lt;P&gt;3)&amp;nbsp;only save ID that appears&amp;nbsp;in every&amp;nbsp;month (it should&amp;nbsp;have&amp;nbsp;&lt;U&gt;at leat&amp;nbsp;&lt;/U&gt;&lt;U&gt;&lt;STRONG&gt;one&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;U&gt;observation&lt;/U&gt;&amp;nbsp;in every month&amp;nbsp;within each year,, from 1990 Jan to 2000 Dec).&lt;/P&gt;&lt;P&gt;With this condition, would expect to save obs for: aa, bb&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;attached&amp;nbsp;is the sample data.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 16:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253806#M268832</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2016-03-02T16:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: what procedure for saving id exist in all year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253821#M268833</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry, you will need to clarify, post test data in the form of a datastep (even something like the below), and clarify the logic.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1) only save ID that appears&amp;nbsp;in every year; or&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By what do you mean every year, what is the lower and upper bounds?&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2)&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;only save ID that appears&amp;nbsp;in every quarter; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Every quarter, does this mean for each year, or any of the years?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3)&amp;nbsp;only save ID that appears&amp;nbsp;in every&amp;nbsp;&lt;SPAN&gt;month&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Again, is this per year, or overal?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;At a guess at what you want:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data have;
  do id=1 to 5;
    do year=2010 to 2014;
      do month=1 to 12;
        output;
      end;
    end;
  end;
run; 

data have;
  set have;
  if id=2 and month in (3,4) then delete;
  if id=4 and year=2011 then delete;
run;

proc sort data=have out=years nodupkey;
  by id year;
run;

data years (keep=id);
  set years;
  retain lstyear yes;
  by id;
  if first.id then do;
    lstyear=year;
    yes=1;
  end;
  else if year ne lstyear+1 then yes=0;
  if last.id and yes=1 then output;
  lstyear=year;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Will give you list of ID's with consecutive years.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 14:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253821#M268833</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-02T14:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: what procedure for saving id exist in all year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253833#M268834</link>
      <description>&lt;P&gt;Thanks a lot! I will try your code, at the meantime I just updated the original post.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 15:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253833#M268834</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2016-03-02T15:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: what procedure for saving id exist in all year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253840#M268836</link>
      <description>&lt;P&gt;I would say you may be quicker off then, creating a template dataset for each grouping, e.g. one template for year, which has all the expected years (What indicates the two records though? &amp;nbsp;Put that in your template too:):&lt;/P&gt;
&lt;P&gt;data years;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; do year=1900 to 2015;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; do sampleid=1 to 2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then merging that back to the main data and keeping where a year/sampleid is missing. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 15:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253840#M268836</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-02T15:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: what procedure for saving id exist in all year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253843#M268837</link>
      <description>&lt;P&gt;thank you for your advice. I am working on the template dataset.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 15:32:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253843#M268837</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2016-03-02T15:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: what procedure for saving id exist in all year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253849#M268838</link>
      <description>&lt;P&gt;I'm not quite sure of your desired output. You repeatedly say "save" but if an ID failys the "every month" test it could pass the "every year" test.&lt;/P&gt;
&lt;P&gt;So this looks like you want three separate data sets, is that correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What will you do with the output if so?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 15:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253849#M268838</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-03-02T15:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: what procedure for saving id exist in all year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253866#M268839</link>
      <description>&lt;P&gt;Yes, three different datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking to create a variable of year_quarter and a variable of year_month;&lt;/P&gt;&lt;P&gt;Then count their frequency with condition on year, on&amp;nbsp;&lt;SPAN&gt;year_quarter or on year_month;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then if the frequency counted is below the required level in one occasition, that id will be deleted.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the problem is that, some IDs have&amp;nbsp;no observation&amp;nbsp;for entire quarter or entire year, frequency will not be counted for that missing periods.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 16:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-procedure-for-saving-id-exist-in-all-year/m-p/253866#M268839</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2016-03-02T16:25:39Z</dc:date>
    </item>
  </channel>
</rss>

