<?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: Indicate decades from dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442238#M110622</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;decade = floor(year(date)/10) * 10 ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 05 Mar 2018 04:07:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-03-05T04:07:55Z</dc:date>
    <item>
      <title>Indicate decades from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442233#M110619</link>
      <description>&lt;P&gt;I am working with the data set&amp;nbsp;TopGrossingAlbumsR.txt, triying to create a new character variable that indicates the decade when the album was released.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure about the right way to approach this question. How should I initialize the char variable? how could I specify the date format in the IF statement and finally, how could I assign the value of decade to my new variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The values of 'ReleaseDate' are written in the format:&amp;nbsp;&lt;SPAN&gt;30NOV1982&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want my new char variable 'Decade' to indicate 1980 for this example.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it is my code and I have attached the data set below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA music;&lt;BR /&gt;INFILE '/folders/myfolders/TopGrossingAlbumsR.txt' dsd firstobs=2;&lt;BR /&gt;LENGTH Album $80. Artist $50. Genre $20.;&lt;BR /&gt;INFORMAT ReleaseDate ANYDTDTE.;&lt;BR /&gt;FORMAT ReleaseDate DATE9.;&lt;BR /&gt;&lt;BR /&gt;INPUT Album Artist ReleaseDate TotalCertifiedCopies ClaimedSales Genre;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;PROC PRINT DATA = music;&lt;BR /&gt;	FORMAT ReleaseDate DATE. ;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;DATA music;&lt;BR /&gt;   SET music;&lt;BR /&gt;   Decade = ' ';&lt;BR /&gt;&lt;BR /&gt;   IF ReleaseDate = ' ' THEN Decade = YYYY;&lt;BR /&gt;   &lt;BR /&gt;   IF Genre = 'Metal' THEN Genre = 'Rock';&lt;BR /&gt;   IF Genre = 'Grunge' THEN Genre = 'Rock';&lt;BR /&gt;   IF Genre = 'Soundtrack' THEN Genre = 'Other';&lt;BR /&gt;   IF Genre = 'Country' THEN Genre = 'Other';&lt;BR /&gt;RUN; &lt;BR /&gt;&lt;BR /&gt;PROC PRINT DATA = music;&lt;BR /&gt;RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 04:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442233#M110619</guid>
      <dc:creator>Miah</dc:creator>
      <dc:date>2018-03-05T04:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Indicate decades from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442235#M110620</link>
      <description>&lt;P&gt;First explain in words what you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then show the data, then the&amp;nbsp;code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, if you have 1990, what do you want, 90? 1990?&lt;/P&gt;
&lt;P&gt;If 2000, do you want 00? or 2000?&lt;/P&gt;
&lt;P&gt;How will you tell 2010 from 1910?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194785"&gt;@Miah&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I am working with the data set&amp;nbsp;TopGrossingAlbumsR.txt, triying to create a new character variable that indicates the decade when the album was released.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure about the right way to approach this question. How should I initialize the char variable? how could I specify the date format in the IF statement and finally, how could I assign the value of decade to my new variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here it is my code and I have attached the data set below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA music;&lt;BR /&gt;INFILE '/folders/myfolders/TopGrossingAlbumsR.txt' dsd firstobs=2;&lt;BR /&gt;LENGTH Album $80. Artist $50. Genre $20.;&lt;BR /&gt;INFORMAT ReleaseDate ANYDTDTE.;&lt;BR /&gt;FORMAT ReleaseDate DATE9.;&lt;BR /&gt;&lt;BR /&gt;INPUT Album Artist ReleaseDate TotalCertifiedCopies ClaimedSales Genre;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;PROC PRINT DATA = music;&lt;BR /&gt;	FORMAT ReleaseDate DATE. ;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;DATA music;&lt;BR /&gt;   SET music;&lt;BR /&gt;   Decade = ' ';&lt;BR /&gt;&lt;BR /&gt;   IF ReleaseDate = ' ' THEN Decade = YYYY;&lt;BR /&gt;   &lt;BR /&gt;   IF Genre = 'Metal' THEN Genre = 'Rock';&lt;BR /&gt;   IF Genre = 'Grunge' THEN Genre = 'Rock';&lt;BR /&gt;   IF Genre = 'Soundtrack' THEN Genre = 'Other';&lt;BR /&gt;   IF Genre = 'Country' THEN Genre = 'Other';&lt;BR /&gt;RUN; &lt;BR /&gt;&lt;BR /&gt;PROC PRINT DATA = music;&lt;BR /&gt;RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 03:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442235#M110620</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-05T03:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Indicate decades from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442236#M110621</link>
      <description>&lt;P&gt;The values of 'ReleaseDate' are written in the format:&amp;nbsp;&lt;SPAN&gt;30NOV1982&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want my new char variable 'Decade' to indicate 1980 for this example.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 04:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442236#M110621</guid>
      <dc:creator>Miah</dc:creator>
      <dc:date>2018-03-05T04:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Indicate decades from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442238#M110622</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;decade = floor(year(date)/10) * 10 ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Mar 2018 04:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442238#M110622</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-05T04:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Indicate decades from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442239#M110623</link>
      <description>&lt;P&gt;Do this the &lt;EM&gt;cool&lt;/EM&gt; way with intnx("year10", ...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
DATA music;
   SET music;
   Decade = intnx("year10", releaseDate, 0);
   length decadeTxt $4;
   decadeTxt = cats("'", put(decade, year2.), "s");
   IF Genre = 'Metal' THEN Genre = 'Rock';
   IF Genre = 'Grunge' THEN Genre = 'Rock';
   IF Genre = 'Soundtrack' THEN Genre = 'Other';
   IF Genre = 'Country' THEN Genre = 'Other';
   format decade year2.;
RUN; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Mar 2018 04:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442239#M110623</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-05T04:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Indicate decades from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442242#M110624</link>
      <description>This was straight forward what I needed. Thanks!</description>
      <pubDate>Mon, 05 Mar 2018 04:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442242#M110624</guid>
      <dc:creator>Miah</dc:creator>
      <dc:date>2018-03-05T04:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Indicate decades from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442251#M110628</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
decade=year(releaseDate)-mod(year(releaseDate),10);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Mar 2018 06:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442251#M110628</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-03-05T06:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Indicate decades from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442290#M110648</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;decade = floor(year(date)/10) * 10 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Perfect application of the KISS principle.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 10:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicate-decades-from-dates/m-p/442290#M110648</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-05T10:14:12Z</dc:date>
    </item>
  </channel>
</rss>

