<?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 create labels within 1 column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-labels-within-1-column/m-p/796413#M255564</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415643"&gt;@manthan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently working on a data file called work.import.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need some help. I have a column that I created from timestamp called hOUR_PART&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It basically has different numbers in it reflecting time hours.. e.g. 12, 10, 22 etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to have values in this column to reflect the following&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any numbers between 0-10 should be AM or 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any numbers between 10-12 (should be morning or 2)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any numbers between 12-0 (should be evening or 3)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So Basically I want 1, 2 or 3 to appear instead of the different hours in the column. How would i achieve this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You want custom formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value hour 0-10 = '1' 11-12 = '2' 13-23='3';
run;
data want;
    set have;
    format hour_part hour.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As pointed out by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; your time intervals overlap, I have removed the overlap. If you don't like the way I removed the overlap, it's easy for you to modify.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Feb 2022 22:29:24 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-02-15T22:29:24Z</dc:date>
    <item>
      <title>How to create labels within 1 column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-labels-within-1-column/m-p/796404#M255559</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently working on a data file called work.import.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some help. I have a column that I created from timestamp called hOUR_PART&amp;nbsp;&lt;/P&gt;&lt;P&gt;It basically has different numbers in it reflecting time hours.. e.g. 12, 10, 22 etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to have values in this column to reflect the following&amp;nbsp;&lt;/P&gt;&lt;P&gt;any numbers between 0-10 should be AM or 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any numbers between 10-12 (should be morning or 2)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any numbers between 12-0 (should be evening or 3)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So Basically I want 1, 2 or 3 to appear instead of the different hours in the column. How would i achieve this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 21:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-labels-within-1-column/m-p/796404#M255559</guid>
      <dc:creator>manthan</dc:creator>
      <dc:date>2022-02-15T21:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create labels within 1 column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-labels-within-1-column/m-p/796407#M255561</link>
      <description>&lt;P&gt;Just as an FYI in SAS this is not called labels (I believe that's the SPSS terminology?)&lt;/P&gt;
&lt;P&gt;This would be recoding the data or applying a format. &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1r8ub0jx34xfsn1ppcjfe0u16pc.htm" target="_self"&gt;Labels apply to variable names&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that your intervals overlap in your description so you may need to modify the ranges in your code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A basic way of doing this is IF/THEN statements, see below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assumes your input data set is HAVE, the output data set is WANT and that your variable is named HOUR_PART.&lt;/P&gt;
&lt;P&gt;EDIT: for some reason I assumed you had time values but you have hours already. Modified code to correct for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

if hour_part in (0:9) then day_code = 1;
else if hour_part in (10:12) then day_code=2;
else if hour_part in (13:23) then day_code = 3;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415643"&gt;@manthan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently working on a data file called work.import.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need some help. I have a column that I created from timestamp called hOUR_PART&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It basically has different numbers in it reflecting time hours.. e.g. 12, 10, 22 etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to have values in this column to reflect the following&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any numbers between 0-10 should be AM or 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any numbers between 10-12 (should be morning or 2)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any numbers between 12-0 (should be evening or 3)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So Basically I want 1, 2 or 3 to appear instead of the different hours in the column. How would i achieve this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 22:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-labels-within-1-column/m-p/796407#M255561</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-15T22:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to create labels within 1 column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-labels-within-1-column/m-p/796413#M255564</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415643"&gt;@manthan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently working on a data file called work.import.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need some help. I have a column that I created from timestamp called hOUR_PART&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It basically has different numbers in it reflecting time hours.. e.g. 12, 10, 22 etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to have values in this column to reflect the following&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any numbers between 0-10 should be AM or 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any numbers between 10-12 (should be morning or 2)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any numbers between 12-0 (should be evening or 3)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So Basically I want 1, 2 or 3 to appear instead of the different hours in the column. How would i achieve this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You want custom formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value hour 0-10 = '1' 11-12 = '2' 13-23='3';
run;
data want;
    set have;
    format hour_part hour.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As pointed out by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; your time intervals overlap, I have removed the overlap. If you don't like the way I removed the overlap, it's easy for you to modify.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 22:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-labels-within-1-column/m-p/796413#M255564</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-15T22:29:24Z</dc:date>
    </item>
  </channel>
</rss>

