<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>ProcRun;</title>
	
	<link>http://procrun.com</link>
	<description>Statistics, SAS, and a lot of Running</description>
	<lastBuildDate>Tue, 03 Apr 2012 23:28:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Procrun" /><feedburner:info uri="procrun" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Stamping the SAS Log with all Macro Variable Values</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/bDrJv_Gp7Fs/</link>
		<comments>http://procrun.com/2012/04/03/stamping-the-sas-log-with-all-macro-variable-values/#comments</comments>
		<pubDate>Tue, 03 Apr 2012 23:26:02 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=236</guid>
		<description><![CDATA[The topic of the day around the office was stamping all of the user created macro variables into the log function. I&#8217;ve got a few programs that have a lot (20+) auto-generated dates, etc and the following is just one of the the many ways to print what each macro resolves to into your log [...]]]></description>
			<content:encoded><![CDATA[<p>The topic of the day around the office was stamping all of the user created macro variables into the log function. I&#8217;ve got a few programs that have a lot (20+) auto-generated dates, etc and the following is just one of the the many ways to print what each macro resolves to into your log file.</p>
<p>Code:</p>
<pre class="brush: text; gutter: true; first-line: 1">data _null_;
  y = today();
  x = intnx('month',y,-1);
  call symput('prev_month',strip(put(x,monname9.)));
  call symput('today',put(y,yymmddn8.));
run;

data _null_;
 set sashelp.vmacro;
 where value &gt; "" and scope = "GLOBAL"
       and substr(name, 1, 3) not in ('SQL','SYS');
 put "Macro Variable: " name  "resolves to: " value;
run;</pre>
<p>Output into the Log File:</p>
<pre class="brush: text; gutter: true; first-line: 1">1    data _null_;
2      y = today();
3      x = intnx('month',y,-1);
4      call symput('prev_month',strip(put(x,monname9.)));
5      call symput('today',put(y,yymmddn8.));
6    run;</pre>
<pre class="brush: text; gutter: true; first-line: 1">NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds

7   data _null_;
8    set sashelp.vmacro;
9    where value &gt; "" and scope = "GLOBAL"
10          and substr(name, 1, 3) not in ('SQL','SYS');
11   put "Macro Variable: " name  "resolves to: " value;
12  run;

Macro Variable: PREV_MONTH resolves to: March
Macro Variable: TODAY resolves to: 20120403
NOTE: There were 2 observations read from the data set SASHELP.VMACRO.
      WHERE (value&gt;' ') and (scope='GLOBAL') and
      SUBSTR(name, 1, 3) not in ('SQL', 'SYS');
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds</pre>
<p>The where clause of the second data step can be edited to include the SQL and SYSTEM macro variables if need be and / or the scope can be change to print just the local macro variables with a macro (if you put the code inside of the macro).</p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/bDrJv_Gp7Fs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2012/04/03/stamping-the-sas-log-with-all-macro-variable-values/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://procrun.com/2012/04/03/stamping-the-sas-log-with-all-macro-variable-values/</feedburner:origLink></item>
		<item>
		<title>Rails and Recent d3.js Examples</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/AjUceuEIPq4/</link>
		<comments>http://procrun.com/2012/02/27/rails-and-recent-d3-js-examples/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 00:35:59 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[d3]]></category>
		<category><![CDATA[SAS]]></category>
		<category><![CDATA[Visulization]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=218</guid>
		<description><![CDATA[A lot of my free time has been spent running and developing a running log using rails.  I want greater control of monitoring / visualizing each training cycle than the sites out there will let me have (no API&#8217;s..).   Thus, I&#8217;ll just build my own! This whole thing was spurred by my dabbling in [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of my free time has been spent running and developing a running log using rails.  I want greater control of monitoring / visualizing each training cycle than the sites out there will let me have (no API&#8217;s..).   Thus, I&#8217;ll just build my own!</p>
<p>This whole thing was spurred by my dabbling in d3.  It&#8217;s pretty much the most awesome and only visualization library you&#8217;ll need.   I&#8217;ve been slowly adding links to all of the example graphics I&#8217;ve put together to the <a href="http://procrun.com/d3-examples/">d3 Examples Page</a>.</p>
<p>There are three out there right now that&#8217;ll let you see what I&#8217;ve done so far&#8230;</p>
<ul>
<li><a href="http://www.procrun.com/d3_examples/last.fm_bar/" target="_blank">Last.fm_bar</a> – Bar chart of a Last.fm user’s top 50 artists.  Calls the Last.fm api and parses the returned json.  Will update as the user scrobbles more tracks to Last.fm. <strong>Feel FREE to make fun of my music choices in the comments</strong>&#8230;.</li>
<li><a href="http://www.procrun.com/d3_examples/running_7day/" target="_blank">Rolling 7 day Training Load</a> - Area chart of my cumulative 7 day training load for miles run.    Much more useful at analyzing the total stress and cycles that weekly or monthly miles.</li>
<li><a href="http://www.procrun.com/d3_examples/running_calendar/" target="_blank">Running Calendar</a> - Calendar view of the daily miles run.  Similar to the <a href="http://procrun.com/2011/11/11/what-5728-986-miles-look-like/" target="_blank">R running calendar</a>.   Adapted from the <a href="http://mbostock.github.com/d3/ex/calendar.html" target="_blank">d3 example</a> which was inspired by Rick Wicklin and Robert Allison’s winning poster (<a href="http://stat-computing.org/dataexpo/2009/posters/wicklin-allison.pdf" target="_blank">pdf</a>).</li>
</ul>
<p>There are a few data sets that I really want to work with but I need to do some serious data cleaning in SAS first.  Writing an json exporter from SAS is next up on the list when I get  a down moment.</p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/AjUceuEIPq4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2012/02/27/rails-and-recent-d3-js-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://procrun.com/2012/02/27/rails-and-recent-d3-js-examples/</feedburner:origLink></item>
		<item>
		<title>Simple Python Scrapper for Daytum</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/6IJr7OQxhnE/</link>
		<comments>http://procrun.com/2012/01/14/simple-python-scrapper-for-daytum/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 23:24:23 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[d3]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=201</guid>
		<description><![CDATA[I use one of the major running sites to keep track of my running log but unfortunately there&#8217;s no public API.  The underlying html is a mess and would be utterly complicated to scrape.   For this training cycle,  I&#8217;ve been keeping a second log using Daytum since their iPhone app makes updating it way easy. [...]]]></description>
			<content:encoded><![CDATA[<p>I use one of the major running sites to keep track of my running log but unfortunately there&#8217;s no public API.  The underlying html is a mess and would be utterly complicated to scrape.   For this training cycle,  I&#8217;ve been keeping a second log using Daytum since their iPhone app makes updating it way easy.</p>
<p>The following  python script scrapes the <a href="http://daytum.com/amcneice/items/1183813" target="_blank">data</a> off of Daytum and outputs a .csv file.</p>
<pre class="brush: python; gutter: false; first-line: 1"># Program: scrapper.py
# Author : Andy McNeice
#
# Purpose: Scrapes my daytum running log and creates a csv file of the
# entries.
import re, urllib2, math, csv
from BeautifulSoup import BeautifulSoup
from datetime import datetime

# Daytum Url
log = urllib2.urlopen('http://daytum.com/amcneice/items/1183813')

# csv output
csv = csv.writer(file(r'data.csv','wb'))

# Constants
parse = [] # holder for Beautiful Soup finds
data = [] # final array

# Use BeautifulSoup to scrap to the Webpage
html = log.read()
soup = BeautifulSoup(html)

# Iterate through the soup to find the text matching the regular expressions
for text in soup.findAll(text=True):
  if re.search(r"\d{1,}\.\d{1,}", text):
    if not (re.search('Total',text) or re.search('DOC',text)):
      parse.append(text.strip())
  elif re.search(r"\d{2}\/\d{2}\/\d{4}", text):
      temp = re.compile(',').split(text)
      parse.append(datetime.strptime(temp[0].strip(),"%m/%d/%Y").strftime("%Y-%m-%d"))
      parse.append(temp[1].strip())

# Manipulate parsed data from long form into multidimensional array
for i in range(0, len(parse)/3):
 data.append([])
 for j in xrange(3):
   data[i].append(parse[i*3+j])

# Sort by day
data.sort(key=lambda x: x[1])

# csv headers for label data
data.insert(0, [])
data[0].append("Miles")
data[0].append("Time")
data[0].append("Time of Day")

# Write out csv to use data elsewhere
csv.writerows(data)</pre>
<p>The Beautiful Soup code is a bit of a mess and will only work for quantitative data at the moment.  It was easier for me to use regular expressions to pluck the important info out of the soup that try to parse based on the underlying html tags.</p>
<p>Right now the script is kicked off by a cron job each hour to capture any updates.  Eventually I&#8217;ll have a pretty awesome dashboard (using <a href="https://github.com/mbostock/d3" target="_blank">d3</a>) to monitor each of my training cycles.</p>
<p>I&#8217;m not a python guru, so if you&#8217;ve got suggestions on how to clean up the code,  I&#8217;m all ears.</p>
<p><a href="https://github.com/AMcNeice/Running" target="_blank">Full code and output .csv available on github.</a></p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/6IJr7OQxhnE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2012/01/14/simple-python-scrapper-for-daytum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://procrun.com/2012/01/14/simple-python-scrapper-for-daytum/</feedburner:origLink></item>
		<item>
		<title>Find Errors and Warnings Quickly</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/liyNGhMxwFk/</link>
		<comments>http://procrun.com/2012/01/05/find-errors-and-warnings-quickly/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 11:49:36 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=198</guid>
		<description><![CDATA[Need to find all of the errors and warnings in your SAS Log quickly? Unleash the following while inside the log&#8217;s directory while on any *nix based OS. egrep '(ERROR:&#124;WARNING)' I save a lot of time scanning the 10,000+ line log files some of the automated jobs create.]]></description>
			<content:encoded><![CDATA[<p>Need to find all of the errors and warnings in your SAS Log quickly?</p>
<p>Unleash the following while inside the log&#8217;s directory while on any *nix based OS.</p>
<pre class="brush: shell; gutter: false; first-line: 1">egrep '(ERROR:|WARNING)'</pre>
<p>I save a lot of time scanning the 10,000+ line log files some of the automated jobs create.</p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/liyNGhMxwFk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2012/01/05/find-errors-and-warnings-quickly/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://procrun.com/2012/01/05/find-errors-and-warnings-quickly/</feedburner:origLink></item>
		<item>
		<title>How many days until?</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/kWqztxq_IP4/</link>
		<comments>http://procrun.com/2011/12/12/how-many-days-until/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 23:39:40 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=194</guid>
		<description><![CDATA[A simple little macro I whipped up that&#8217;ll count down the number of days until an important event. %macro daysUntil(event, date); data _null_; diff = datdif(today(), input("&#38;date.", anydtdte10.), 'act/act'); call symput('days_until', strip(diff)); run; %put There are &#38;days_until days until &#38;event; %mend; Macro call is straight forward: %daysUntil(Christmas, 12/25/2011); %daysUntil(Columbia_Marathon, 03/10/2012); I could have used various [...]]]></description>
			<content:encoded><![CDATA[<p>A simple little macro I whipped up that&#8217;ll count down the number of days until an important event.</p>
<pre class="brush: text; gutter: false; first-line: 1">%macro daysUntil(event, date);
  data _null_;
    diff = datdif(today(), input("&amp;date.", anydtdte10.), 'act/act');
    call symput('days_until', strip(diff));
  run;

  %put There are &amp;days_until days until &amp;event;
%mend;</pre>
<p>Macro call is straight forward:</p>
<pre class="brush: text; gutter: false; first-line: 1">%daysUntil(Christmas, 12/25/2011);
%daysUntil(Columbia_Marathon, 03/10/2012);</pre>
<pre class="brush: text; gutter: false; first-line: 1"></pre>
<p>I could have used various intnx() commands to account for the differences in months, days and years.  There&#8217;s some good stuff out there on how to pull that off if it&#8217;s what you fancy.</p>
<p>The <a href="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p1gz65986b9jqin19zk9xqbi7ns3.htm">datdif() documentation</a> is worth looking at.</p>
<p>As always, <a href="https://bitbucket.org/procrun/sas-snippets/src/81d8dae886d4/daysUntil.sas">full source file is available here on bitbucket.</a></p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/kWqztxq_IP4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2011/12/12/how-many-days-until/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://procrun.com/2011/12/12/how-many-days-until/</feedburner:origLink></item>
		<item>
		<title>Clearning up the sqldf confusion</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/YM9i87pstTk/</link>
		<comments>http://procrun.com/2011/11/30/clearning-up-the-sqldf-confusion/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 02:42:29 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=173</guid>
		<description><![CDATA[Apparently I have issues with my reading comprehension and with Textmate (initially) when it comes to using the sqldf package. G. pointed out in the previous comments, I could have just used options(gsubfn.engine = "R") instead of going through the trouble of installing the tcltk binaries. If you&#8217;ve got a happy distribution of R that [...]]]></description>
			<content:encoded><![CDATA[<p>Apparently I have issues with my reading comprehension and with Textmate (initially) when it comes to using the sqldf package.</p>
<p>G. pointed out in the <a href="http://procrun.com/2011/11/18/fbs-coaches-avg-salary/comment-page-1/#comment-440" target="_blank">previous comment</a>s, I could have just used</p>
<pre class="brush: text; gutter: false; first-line: 1">options(gsubfn.engine = "R")</pre>
<p>instead of going through the trouble of installing the tcltk binaries.</p>
<p>If you&#8217;ve got a happy distribution of R that comes with the working binaries, you can run sqldf and not have to worry about anything. Otherwise update the <code>gsubfn</code> and use the options setting.</p>
<p>When in doubt, check and actually READ (whoops..) the FAQ: <a href="http://code.google.com/p/sqldf/" target="_blank">http://code.google.com/p/sqldf/</a></p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/YM9i87pstTk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2011/11/30/clearning-up-the-sqldf-confusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://procrun.com/2011/11/30/clearning-up-the-sqldf-confusion/</feedburner:origLink></item>
		<item>
		<title>FBS Coaches Avg. Salary</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/lMFqVc2sXK8/</link>
		<comments>http://procrun.com/2011/11/18/fbs-coaches-avg-salary/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 15:35:27 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[Sports]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=174</guid>
		<description><![CDATA[Of course, a few days before I leave for a much needed vacation, USA Today released their updated NCAA coaching salary database. For sports junkies, there&#8217;s an unlimited number of analysis and visualizations that can be done on the data. I took a quick break from packing to condense the data to a csv and [...]]]></description>
			<content:encoded><![CDATA[<p>Of course, a few days before I leave for a much needed vacation, USA Today released their updated <a href="http://www.usatoday.com/sports/college/football/story/2011-11-17/cover-college-football-coaches-salaries-rise/51242232/1">NCAA coaching salary database</a>. For sports junkies, there&#8217;s an unlimited number of analysis and visualizations that can be done on the data.</p>
<p>I took a quick break from packing to condense the <a href="https://bitbucket.org/procrun/code/src/92035ed93ee3/CoachesSalary">data to a csv</a> and write up a very rough R script. Note:  <a href="http://code.google.com/p/sqldf/">sqldf rocks</a> but <a href="http://code.google.com/p/sqldf/#5._I_get_a_message_about_tcl_being_missing.">installing tcltk (if you have too)</a> can be a bit of a pain. <a href="https://stat.ethz.ch/pipermail/r-help/2010-November/258276.html">Look here for help with tcltk. </a></p>
<pre class="brush: text; gutter: false; first-line: 1">
library(ggplot2)
library(sqldf)

salaries <- read.csv("2011Salary.csv", header=T, sep=",")

result <- sqldf('select
                  a.Conference,
                  sum(a.SchoolPay) / b.spc as avg_pay
                from
                  salaries  as a
                join
                  (select Conference, count(*) as spc
                  from salaries
                  where SchoolPay > 0
                  group by Conference) as b
                on
                  a.Conference = b.Conference
                group by
                  a.Conference')

chart <- qplot(result$Conference, result$avg_pay,
                geom="bar",
                stat="identity",
                fill = I("grey50"),
                main = 'Average Coaches Salary by Conference',
                xlab = 'Conference',
                ylab = 'Average Pay')

chart + opts(axis.text.x=theme_text(angle=-45))
</pre>
<p><a href="https://stat.ethz.ch/pipermail/r-help/2010-November/258276.html"><br />
</a>Outputs the following</p>
<p><a href="http://procrun.com/wp-content/uploads/2011/11/CoachesSalary.png"><img class="alignnone size-full wp-image-175" title="CoachesSalary" src="http://procrun.com/wp-content/uploads/2011/11/CoachesSalary.png" alt="" width="600" height="600" /></a></p>
<p>Most surprising result? PAC-12 coaches average ~ $400,000 less than the Big East.</p>
<p><a href="https://bitbucket.org/procrun/code/src/04dc045e7223/CoachesSalary" target="_blank"><em>Full code is available on bitbucket.</em></a></p>
<p>Edited per G.'s suggestion:  sqldf rocks,  tcltk can be tricky.</p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/lMFqVc2sXK8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2011/11/18/fbs-coaches-avg-salary/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://procrun.com/2011/11/18/fbs-coaches-avg-salary/</feedburner:origLink></item>
		<item>
		<title>What 5,728.986 miles look like…</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/-PZ6VRrBEoE/</link>
		<comments>http://procrun.com/2011/11/11/what-5728-986-miles-look-like/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 03:42:06 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[Sports]]></category>
		<category><![CDATA[Visulization]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=163</guid>
		<description><![CDATA[Time Series as calendar heat maps + All of my running data since April 1, 2009 = Generated by the following code: #Sample Code based on example program at: source(file = "calendarHeat.R") run&#60;- read.csv("log.csv", header = TRUE, sep=",") sum(run$Distance) date &#60;- c() for (i in 1: dim(run)[1]){ if(run$DistanceUnit[i]== 'Kilometer'){ miles &#60;- c(miles,run$Distance[i] * 0.62) } [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.revolutionanalytics.com/2009/11/charting-time-series-as-calendar-heat-maps-in-r.html" target="_blank">Time Series as calendar heat maps</a> + <a href="http://procrun.com/wp-content/uploads/2011/11/log.csv">All of my running data since April 1, 2009</a> =</p>
<p><a href="http://procrun.com/wp-content/uploads/2011/11/BigHeatMap.png"><img class="alignnone size-full wp-image-168" title="thumbnail" src="http://procrun.com/wp-content/uploads/2011/11/thumbnail.png" alt="" width="600" height="450" /></a></p>
<p>Generated by the following code:</p>
<pre class="brush: text; gutter: false; first-line: 1">#Sample Code based on example program at:
source(file = "calendarHeat.R")

run&lt;- read.csv("log.csv", header = TRUE, sep=",")
sum(run$Distance)

date &lt;- c()

for (i in 1: dim(run)[1]){

    if(run$DistanceUnit[i]== 'Kilometer'){
      miles &lt;- c(miles,run$Distance[i] * 0.62)
    }
    else{
      miles &lt;- c(miles,run$Distance[i])
    }
}
sum(miles)

calendarHeat(run$Date, miles, varname="Andy's Running Mileage")</pre>
<p>You can see the definite shift in the length of my daily runs over the past 12 months.  Race times have dropped a chunk over that same period.</p>
<p>The heat map still needs some cleaning up,  using 26.2 as the max intensity is preventing the differences in my shorter runs from coming through.  Capping it at max of 15 (shortest of my &#8216;long&#8217; runs) is probably a good idea to further show the shift in my daily mileage.</p>
<p>One of these days I need to transfer the 4,534.62 miles I have logged into notebooks to the computer.   Buying a Garmin Forerunner and having the data automatically updated to Runningahead.com  made it super easy to get the dataset.</p>
<p>Full code and source files are available on bitbucket:  <a href="https://bitbucket.org/procrun/code/src/55432b9c00c0/RunHeatMap/">RunningHeatMap</a></p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/-PZ6VRrBEoE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2011/11/11/what-5728-986-miles-look-like/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://procrun.com/2011/11/11/what-5728-986-miles-look-like/</feedburner:origLink></item>
		<item>
		<title>SAS Error Message with an Attitude</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/pybgY8c0RoA/</link>
		<comments>http://procrun.com/2011/10/28/sas-error-message-with-an-attitude/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 23:31:59 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[SAS]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=155</guid>
		<description><![CDATA[I may have giggled snorted bellowed with laughter when I saw this error message in my log today. NOTE: There were 0 observations read from the data set WORK.TEST. WHERE 0 /* an obviously FALSE WHERE clause */ ; NOTE: The data set WORK.TEST has 0 observations and 15 variables. NOTE: DATA statement used (Total [...]]]></description>
			<content:encoded><![CDATA[<p>I may have <del>giggled</del> <del>snorted</del> bellowed with laughter when I saw this error message in my log today.</p>
<pre class="brush: text; gutter: false; first-line: 1">NOTE: There were 0 observations read from the data set WORK.TEST.
      WHERE 0 /* an obviously FALSE WHERE clause */ ;
NOTE: The data set WORK.TEST has 0 observations and 15 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.00 seconds</pre>
<p>There&#8217;s a software developer with a sense of humor somewhere in Cary, NC.</p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/pybgY8c0RoA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2011/10/28/sas-error-message-with-an-attitude/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://procrun.com/2011/10/28/sas-error-message-with-an-attitude/</feedburner:origLink></item>
		<item>
		<title>Variable Names into Macro Variables</title>
		<link>http://feedproxy.google.com/~r/Procrun/~3/GClrZJOKDyY/</link>
		<comments>http://procrun.com/2011/10/21/variable-names-into-macro-variables/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 18:29:27 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Helpful Tricks]]></category>
		<category><![CDATA[SAS]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://procrun.com/?p=140</guid>
		<description><![CDATA[Late last month, I posted an answer to a question on StackOverflow. This morning, I had to use something similar at work and it reminded me that ability to pull variable names out of a data set is a handy trick. For the example, I&#8217;m using the yr1001 data set from sashelp to avoid sending [...]]]></description>
			<content:encoded><![CDATA[<p>Late last month, I posted an answer to <a href="http://stackoverflow.com/questions/7591149/performing-tests-over-variables-in-sas/7598980#7598980">a question</a> on StackOverflow. This morning, I had to use something similar at work and it reminded me that ability to pull variable names out of a data set is a handy trick.</p>
<p>For the example, I&#8217;m using the yr1001 data set from sashelp to avoid sending proc ttest a variable with qualitative data. Be forewarned, there are 505 variables within the data set, you may want to choose a set with fewer variables if you have performance concerns.</p>
<p>Variable names come from <em>proc contents</em>. If you want to iterate over each data set in the library instead, swap our sashelp.yr1000 with somelib._all_. <em>Proc contents</em> spits out a lot of information about each variable, but for this example, we only need the name.</p>
<pre class="brush: text; gutter: false; first-line: 1">*--- Get all the variable names from the data set ---;
proc contents data = sashelp.yr1001
		     out = names (keep = name)
		     noprint;
run;</pre>
<pre class="brush: text; gutter: false; first-line: 1"></pre>
<p><code></code>Select each variable name into a unique macro variable. SAS is smart enough to only keep the variables it actually uses in memory. <em>Count</em> is the stop variable to keep the loops from going out of bounds.<code> </code> </p>
<pre class="brush: text; gutter: false; first-line: 1">*--- Put count and distinct names into macro variables ---;
proc sql;
 select
 	distinct name,
	count(distinct name)
 into
 	:name1 - :name9999,
	:count
 from
	names
 where
 	substr(name, 1, 1) = 'S';
quit;</pre>
<p><code></code>Stamp the log with each variable. Useful for checking to make sure the code worked the way it should.</p>
<pre class="brush: text; gutter: false; first-line: 1">*--- List all of the variables in the log ---;
%macro loop();
 %do i = 1 %to &amp;count.;
   %put &amp;&amp;name&amp;i.;
 %end;
%mend;
%loop();</pre>
<p><code></code>Perform some procedure over each variables. Be careful of variable types and syntax for any procedure run.<br />
<code></code></p>
<pre class="brush: text; gutter: false; first-line: 1">*--- Instead of listing to the log, perform some other proc ---;
%macro loop2();
 %do i = 1 %to &amp;count.;
  proc ttest data = sashelp.yr1001;
   var &amp;&amp;name&amp;i.;
  run;
 %end;
%mend;
%loop2();</pre>
<p>That should get you started on splitting apart data sets and libraries using <em>proc contents</em>.  I&#8217;ve found the ability to send the <em>proc contents</em> results to a file the most important feature of <em>proc contents</em> by far.</p>
<p>Full program is available for download from bitbucket: <a href="https://bitbucket.org/procrun/sas-snippets/src" target="_blank">varNamesToMacros.sas</a></p>
<img src="http://feeds.feedburner.com/~r/Procrun/~4/GClrZJOKDyY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://procrun.com/2011/10/21/variable-names-into-macro-variables/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://procrun.com/2011/10/21/variable-names-into-macro-variables/</feedburner:origLink></item>
	</channel>
</rss>

