<?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: computation from 200001 to 201012 [how to improve your question] in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500522#M133319</link>
    <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
    <pubDate>Mon, 01 Oct 2018 19:33:09 GMT</pubDate>
    <dc:creator>Community_Guide</dc:creator>
    <dc:date>2018-10-01T19:33:09Z</dc:date>
    <item>
      <title>computation from 200001 to 201012</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500486#M133301</link>
      <description>&lt;P&gt;how can I rewrite the following codes in order to make the computation from 200001 to 201012?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL; &lt;BR /&gt;CREATE table step4.Y_number_of_pat AS
 SELECT
  co.psn_name,
  COUNT (distinct(case WHEN earliest_filing_year =2000 THEN DOCDB_FAMILY_ID END)) AS application2000,
  COUNT (distinct(case WHEN earliest_filing_year =2001 THEN DOCDB_FAMILY_ID END)) AS application2001,
  COUNT (distinct(case WHEN earliest_filing_year =2002 THEN DOCDB_FAMILY_ID END)) AS application2002,
  COUNT (distinct(case WHEN earliest_filing_year =2003 THEN DOCDB_FAMILY_ID END)) AS application2003,
  COUNT (distinct(case WHEN earliest_filing_year =2004 THEN DOCDB_FAMILY_ID END)) AS application2004,
  COUNT (distinct(case WHEN earliest_filing_year =2005 THEN DOCDB_FAMILY_ID END)) AS application2005,
  COUNT (distinct(case WHEN earliest_filing_year =2006 THEN DOCDB_FAMILY_ID END)) AS application2006,
  COUNT (distinct(case WHEN earliest_filing_year =2007 THEN DOCDB_FAMILY_ID END)) AS application2007,
  COUNT (distinct(case WHEN earliest_filing_year =2008 THEN DOCDB_FAMILY_ID END)) AS application2008,
  COUNT (distinct(case WHEN earliest_filing_year =2009 THEN DOCDB_FAMILY_ID END)) AS application2009,
  COUNT (distinct(case WHEN earliest_filing_year =2010 THEN DOCDB_FAMILY_ID END)) AS application2010
 FROM Step1.appln_new AS ap 
 JOIN Pat_ori.Personapplication AS pe ON ap.appln_id = pe.appln_id
 JOIN Pat_ori.Companies AS co ON pe.person_id = co.person_id
 WHERE applt_seq_nr &amp;gt; 0 /* only include patent applicants */
 GROUP BY psn_name
 ORDER BY psn_name
; 
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I count the number of distinct DOCDB_FAMILY_ID&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;per year&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;by using the above codes. but now I'd like to count the number of distinct DOCDB_FAMILY_ID&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;per month&lt;/STRONG&gt;. I will have to use the code like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;COUNT (distinct(case WHEN earliest_filing_date =200001 THEN DOCDB_FAMILY_ID END)) AS application200001,
COUNT (distinct(case WHEN earliest_filing_date =200002 THEN DOCDB_FAMILY_ID END)) AS application200002,
...
COUNT (distinct(case WHEN earliest_filing_date =201012 THEN DOCDB_FAMILY_ID END)) AS application201012&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and copy it hundreds time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please give me some suggestions to simplify the codes?&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 17:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500486#M133301</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-10-01T17:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: computation from 200001 to 201012 [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500522#M133319</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
      <pubDate>Mon, 01 Oct 2018 19:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500522#M133319</guid>
      <dc:creator>Community_Guide</dc:creator>
      <dc:date>2018-10-01T19:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: computation from 200001 to 201012 [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500533#M133321</link>
      <description>&lt;P&gt;If you have an actual date value then you can create groups based on the formatted values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example with a data set you should have available.&lt;/P&gt;
&lt;PRE&gt;proc summary data= sashelp.stocks nway;
   class stock date;
   format date yymmn6.;
   var open high low close volume;
   output out=work.example (drop=_freq_) mean=;
run;&lt;/PRE&gt;
&lt;P&gt;NWAY only shows the combinations of Class variables that all the variables contribute to, otherwise you get combination of all records, stock only, date only as well as the stock date combination. The date is actually a trading date. The format yymmn6 says to group the values by calendar month and display as 198608 for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Class variables would be the equivalent of group by variables. The N statistic instead of Mean= would count non-missing.&lt;/P&gt;
&lt;P&gt;It is really generally a much better idea to summarize into a single variable with group membership shown with the date variable.&lt;/P&gt;
&lt;P&gt;Then if you need something human readable to use the date as an across variable for example.&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sashelp.stocks;
   class stock date;
   format date yymmn6.;
   var open high low close volume;
   table stock=''*(open high low),
         date='Monthly mean'* (mean='');
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Oct 2018 19:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500533#M133321</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-01T19:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: computation from 200001 to 201012</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500648#M133358</link>
      <description>&lt;P&gt;Putting data (month and year) into variable names is generally not a good idea. Why not just do the computation "lengthwise" (more observations, fewer variables):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL; 
CREATE table step4.Y_number_of_pat AS
 SELECT
  co.psn_name,
  COUNT (distinct(DOCDB_FAMILY_ID) AS application,
  earliest_filing_year,
  month
 FROM Step1.appln_new AS ap 
 JOIN Pat_ori.Personapplication AS pe ON ap.appln_id = pe.appln_id
 JOIN Pat_ori.Companies AS co ON pe.person_id = co.person_id
 WHERE applt_seq_nr &amp;gt; 0 /* only include patent applicants */
 GROUP BY psn_name,earliest_filing_year,month
 ORDER BY psn_name,earliest_filing_year,month
; 
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you think you absolutely must have the data format with many variables (and not just a report with year or month across, use PROC REPORT for that), it is much easier to apply a PROC TRANSPOSE step to your SQL output data.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 08:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500648#M133358</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-10-02T08:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: computation from 200001 to 201012</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500707#M133378</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;how can I rewrite the following codes in order to make the computation from 200001 to 201012?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL; 
CREATE table step4.Y_number_of_pat AS
 SELECT
  co.psn_name,
  COUNT (distinct(case WHEN earliest_filing_year =2000 THEN DOCDB_FAMILY_ID END)) AS application2000,
  COUNT (distinct(case WHEN earliest_filing_year =2001 THEN DOCDB_FAMILY_ID END)) AS application2001,
   ...
; 
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I count the number of distinct DOCDB_FAMILY_ID&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;per year&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;by using the above codes. but now I'd like to count the number of distinct DOCDB_FAMILY_ID&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;per month&lt;/STRONG&gt;. I will have to use the code like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;COUNT (distinct(case WHEN earliest_filing_date =200001 THEN DOCDB_FAMILY_ID END)) AS application200001,
COUNT (distinct(case WHEN earliest_filing_date =200002 THEN DOCDB_FAMILY_ID END)) AS application200002,
...
COUNT (distinct(case WHEN earliest_filing_date =201012 THEN DOCDB_FAMILY_ID END)) AS application201012&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and copy it hundreds time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;could you please give me some suggestions to simplify the codes?&lt;/P&gt;
&lt;P&gt;thanks in advance.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As others have said, we need to know WHY you want variables application200001 through application201012. Most of the time, this is unnecessary work, and you can use earliest_filing_date rather than the variables named application200001 etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are just counting the number of occurrences (which seems to be what your SQL code is doing), then there are other ways to do this, such as GROUP BY in SQL, or PROC MEANS/PROC SUMMARY/PROC FREQ.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 12:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computation-from-200001-to-201012/m-p/500707#M133378</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-02T12:30:41Z</dc:date>
    </item>
  </channel>
</rss>

