<?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 to break up a series of values in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-break-up-a-series-of-values-in-SAS/m-p/391988#M277721</link>
    <description>Probably the easiest way would be to use a substr() function combined with the input() function. It would look something like this:&lt;BR /&gt;&lt;BR /&gt;data out;&lt;BR /&gt;set in;&lt;BR /&gt;year=input(substr(date,1,4),4.0);&lt;BR /&gt;month=input(substr(date,5,2),2.0);&lt;BR /&gt;day=input(substr(date,7,2),2.0);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;You could also use an informat to turn the character variable into a date variable:&lt;BR /&gt;&lt;BR /&gt;data test1;&lt;BR /&gt;format date mmddyy8.;&lt;BR /&gt;input &lt;BR /&gt;	date : yymmdd8.&lt;BR /&gt;; &lt;BR /&gt;datalines;&lt;BR /&gt;20170816&lt;BR /&gt;20160421&lt;BR /&gt;20150725&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;</description>
    <pubDate>Wed, 30 Aug 2017 19:05:22 GMT</pubDate>
    <dc:creator>ebowen</dc:creator>
    <dc:date>2017-08-30T19:05:22Z</dc:date>
    <item>
      <title>How to break up a series of values in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-break-up-a-series-of-values-in-SAS/m-p/391981#M277719</link>
      <description>&lt;P&gt;I have a date column that I would like to break up into Year, Month, Day, however it is in a format that is not regularly condusive to usual SAS methods.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is a character variable and set up YYYYMMDD. &amp;nbsp;How would I break this up so it could be YYYY in one column, MM in another, and DD in a third?&lt;BR /&gt;&lt;BR /&gt;Let me know if you need any other information.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 18:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-break-up-a-series-of-values-in-SAS/m-p/391981#M277719</guid>
      <dc:creator>jswinford</dc:creator>
      <dc:date>2017-08-30T18:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to break up a series of values in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-break-up-a-series-of-values-in-SAS/m-p/391983#M277720</link>
      <description>&lt;P&gt;substring function is one option. For example, year = substr(your_yyyymmdd_var, 1, 4);&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For conversion to a numeric field, nest it in an input function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;year = input(substr(var, 1, 4), best.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do likewise for the three other columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, convert to a date and extract the year, month, and day:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;year = year(input(var, yymmdd8.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 18:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-break-up-a-series-of-values-in-SAS/m-p/391983#M277720</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-08-30T18:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to break up a series of values in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-break-up-a-series-of-values-in-SAS/m-p/391988#M277721</link>
      <description>Probably the easiest way would be to use a substr() function combined with the input() function. It would look something like this:&lt;BR /&gt;&lt;BR /&gt;data out;&lt;BR /&gt;set in;&lt;BR /&gt;year=input(substr(date,1,4),4.0);&lt;BR /&gt;month=input(substr(date,5,2),2.0);&lt;BR /&gt;day=input(substr(date,7,2),2.0);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;You could also use an informat to turn the character variable into a date variable:&lt;BR /&gt;&lt;BR /&gt;data test1;&lt;BR /&gt;format date mmddyy8.;&lt;BR /&gt;input &lt;BR /&gt;	date : yymmdd8.&lt;BR /&gt;; &lt;BR /&gt;datalines;&lt;BR /&gt;20170816&lt;BR /&gt;20160421&lt;BR /&gt;20150725&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Aug 2017 19:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-break-up-a-series-of-values-in-SAS/m-p/391988#M277721</guid>
      <dc:creator>ebowen</dc:creator>
      <dc:date>2017-08-30T19:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to break up a series of values in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-break-up-a-series-of-values-in-SAS/m-p/391994#M277722</link>
      <description>&lt;P&gt;I would recommend converting it to a SAS date and then using the YEAR/MONTH/DAY functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if you apply formats to your date they get grouped according to the format, so having a SAS date is advantageous.&lt;/P&gt;
&lt;P&gt;Here's a quick example that shows the calculating of yearly statistics from a data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.stocks min max mean;
class date;
format date year4.;
var open high low;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Aug 2017 19:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-break-up-a-series-of-values-in-SAS/m-p/391994#M277722</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-30T19:21:27Z</dc:date>
    </item>
  </channel>
</rss>

