<?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: Creating a variable to count occurences in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315411#M68790</link>
    <description>&lt;P&gt;It is a raw text file read in. I subsituted the actual pathway for 'HOT.'&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2016 04:16:08 GMT</pubDate>
    <dc:creator>nickc10</dc:creator>
    <dc:date>2016-11-30T04:16:08Z</dc:date>
    <item>
      <title>Creating a variable to count occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315405#M68785</link>
      <description>&lt;P&gt;I have a data set that have 48 temperatures that correspond to two 24 hour days. I want to create a variable that is 1 if it occurs in the first day and 2 if it occurs in the second. I used a do loop to create the Hour variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set hot;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do Hours=1 to 24;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;input temp@@;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315405#M68785</guid>
      <dc:creator>nickc10</dc:creator>
      <dc:date>2016-11-30T04:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable to count occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315407#M68786</link>
      <description>&lt;P&gt;What is the structure of dataset &lt;STRONG&gt;hot?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315407#M68786</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-11-30T04:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable to count occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315408#M68787</link>
      <description>&lt;P&gt;Are you reading SAS data from sas dataset HOT?&amp;nbsp; If so you don't need the INPUT statement which is intended to read raw data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So lets assume you have 48 obs, i.e. 24 for day 1 and 24 for day 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you could do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temps;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set hot;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if _n_&amp;lt;=24 then day=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; else day=2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The automatic variable _N_ above is the iteration number of the data set, which corresponds in this case to the observation number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315408#M68787</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-30T04:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable to count occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315410#M68789</link>
      <description>&lt;P&gt;I was reading in a raw text file, but to save space and some personal details I subsituted the path for 'HOT.' I initially tried to use the _N_ for this, but I can't seem to get it to work correctly with the do loop. Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315410#M68789</guid>
      <dc:creator>nickc10</dc:creator>
      <dc:date>2016-11-30T04:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable to count occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315411#M68790</link>
      <description>&lt;P&gt;It is a raw text file read in. I subsituted the actual pathway for 'HOT.'&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:16:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315411#M68790</guid>
      <dc:creator>nickc10</dc:creator>
      <dc:date>2016-11-30T04:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable to count occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315412#M68791</link>
      <description>&lt;P&gt;Reading raw data? In that case;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; infile '....... path to raw data of temps ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; do day=1 to 2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do hour=1 to 24;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input temp @@;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315412#M68791</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-30T04:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable to count occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315413#M68792</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temps;
    infile "path\myHotFile.txt";
	do day = 1, 2;
		do Hour=1 to 24;
			input temp@@;
			output;
			end;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:23:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315413#M68792</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-11-30T04:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable to count occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315414#M68793</link>
      <description>&lt;P&gt;Perfect! Thanks so much!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315414#M68793</guid>
      <dc:creator>nickc10</dc:creator>
      <dc:date>2016-11-30T04:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a variable to count occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315415#M68794</link>
      <description>&lt;P&gt;Awesome! Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-variable-to-count-occurences/m-p/315415#M68794</guid>
      <dc:creator>nickc10</dc:creator>
      <dc:date>2016-11-30T04:26:43Z</dc:date>
    </item>
  </channel>
</rss>

