<?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 use date formats to reference columns in conditional statements? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453745#M114692</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Thanks for the reply and for trying to help, this is very close to what I need. I have never used the whichc function before. When I run your code in your example I get&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ID&amp;nbsp; Feb2015&amp;nbsp; &amp;nbsp;Mar2015&amp;nbsp; &amp;nbsp;Apr2015&amp;nbsp; May2015&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This didn't really make sense to me because it is showing the value of the of the previous month when I need the value of the current month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;changed&amp;nbsp;the code&amp;nbsp;so that it was&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if i&amp;gt;0 then want=vals(i);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This seemed to work much better and corresponded to the to the values in the SAS_date column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ID&amp;nbsp; Feb2015&amp;nbsp; &amp;nbsp;Mar2015&amp;nbsp; &amp;nbsp;Apr2015&amp;nbsp; May2015&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;2&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Now the only thing I am still confused about this is that my last column is in fact a date and not a character value. How do I change it so that I would be able to work with a date column? Thanks so much for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Apr 2018 20:15:17 GMT</pubDate>
    <dc:creator>Tommy1</dc:creator>
    <dc:date>2018-04-12T20:15:17Z</dc:date>
    <item>
      <title>How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453695#M114673</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I really need is to be able to figure out how to use the SAS date format as a string to reference a column name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a SAS date column that that is in the monyy7. (ex. jan20015) format . For each ID, there may be multiple observations with the only difference being different month values for the SAS_Date column. My data also contains a column for every month that is named in the same format as the dates in the SAS_Date column. What I am trying to do is pull the label from the SAS date format and use that to check what the corresponding value is in the column with the same name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here is an example of what my data looks like&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;Jan2015&amp;nbsp; &amp;nbsp; &amp;nbsp;Feb2015&amp;nbsp; &amp;nbsp; &amp;nbsp;Mar2015&amp;nbsp; &amp;nbsp; Apr2015&amp;nbsp; &amp;nbsp; &amp;nbsp;May2015&amp;nbsp; &amp;nbsp; &amp;nbsp;SAS_Date&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Feb2015&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mar2015&lt;/P&gt;&lt;P&gt;1&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Apr2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Mar2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;May2015&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What I would like to do with this is create one row for each ID. It would take the date from the SAS_Date column and would compare the value from the corresponding row to the previous column. If they are the same then put a blank in that column, if different keep the value of the current month unless the previous month is blank then also put a blank in that current column.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What I would like my data to look like is&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;Jan2015&amp;nbsp; &amp;nbsp; &amp;nbsp;Feb2015&amp;nbsp; &amp;nbsp; &amp;nbsp;Mar2015&amp;nbsp; &amp;nbsp; Apr2015&amp;nbsp; &amp;nbsp; &amp;nbsp;May2015&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;2&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have already created a previous month column with&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format prev_month monyy7.;
prev_month = Intnx('MONTH',SAS_date,-1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;If I can use the label of the date variables&amp;nbsp;I think I will be able to figure out how to do the rest by using&amp;nbsp;IF statements, the concatenate function, and a keep&amp;nbsp;statements and then joining&amp;nbsp;the data. There may be a more efficient way, but this is a way that I figured out&amp;nbsp;how to handle a similar problem in the past.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If there is anything that is unclear please let me know and I will try to clarify.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the help,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 18:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453695#M114673</guid>
      <dc:creator>Tommy1</dc:creator>
      <dc:date>2018-04-12T18:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453702#M114676</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/104359"&gt;@Tommy1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi Community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All I really need is to be able to figure out how to use the SAS date format as a string to reference a column name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a SAS date column that that is in the monyy7. (ex. jan20015) format . For each ID, there may be multiple observations with the only difference being different month values for the SAS_Date column. My data also contains a column for every month that is named in the same format as the dates in the SAS_Date column. What I am trying to do is pull the label from the SAS date format and use that to check what the corresponding value is in the column with the same name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Here is an example of what my data looks like&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;Jan2015&amp;nbsp; &amp;nbsp; &amp;nbsp;Feb2015&amp;nbsp; &amp;nbsp; &amp;nbsp;Mar2015&amp;nbsp; &amp;nbsp; Apr2015&amp;nbsp; &amp;nbsp; &amp;nbsp;May2015&amp;nbsp; &amp;nbsp; &amp;nbsp;SAS_Date&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Feb2015&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mar2015&lt;/P&gt;
&lt;P&gt;1&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Apr2015&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Mar2015&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;May2015&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What I would like to do with this is create one row for each ID. It would take the date from the SAS_Date column and would compare the value from the corresponding row to the previous column. If they are the same then put a blank in that column, if different keep the value of the current month unless the previous month is blank then also put a blank in that current column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What I would like my data to look like is&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;Jan2015&amp;nbsp; &amp;nbsp; &amp;nbsp;Feb2015&amp;nbsp; &amp;nbsp; &amp;nbsp;Mar2015&amp;nbsp; &amp;nbsp; Apr2015&amp;nbsp; &amp;nbsp; &amp;nbsp;May2015&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;2&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have already created a previous month column with&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format prev_month monyy7.;
prev_month = Intnx('MONTH',SAS_date,-1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;If I can use the label of the date variables&amp;nbsp;I think I will be able to figure out how to do the rest by using&amp;nbsp;IF statements, the concatenate function, and a keep&amp;nbsp;statements and then joining&amp;nbsp;the data. There may be a more efficient way, but this is a way that I figured out&amp;nbsp;how to handle a similar problem in the past.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If there is anything that is unclear please let me know and I will try to clarify.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks for the help,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why does your result have missing value for Jan2015 and Feb2015 on the ID 1 row? "Previous column" does NOT have an obvious meaning. Do mean the variable name that corresponds the previous month of the date stored in a given column name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your data seems to have duplicate values except for the SAS_DATE variable value I might suspect an earlier step that created the duplicates and perhaps this could be resolve earlier.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 18:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453702#M114676</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-12T18:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453704#M114677</link>
      <description>&lt;P&gt;Please explain your output with the logic exclusively. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 18:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453704#M114677</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-12T18:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453709#M114678</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Yes you are correct,&lt;SPAN&gt;&amp;nbsp;the previous month corresponds&amp;nbsp;to the column to the left of the one that is being referenced in the SAS_date column&lt;/SPAN&gt;. You are also correct that the duplication is a result of an inner join between two data tables using proc sql in a previous step. I could not think of a more efficient way to merge the data and still capture all the data that I need. Thank you for responding.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 18:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453709#M114678</guid>
      <dc:creator>Tommy1</dc:creator>
      <dc:date>2018-04-12T18:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453715#M114682</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;The logic for the data would be;&lt;/P&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-main"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*In this code the SAS_Date is referring to column that is referenced by the &lt;BR /&gt;value in the SAS_Date column itself since the way to obtain the label &lt;BR /&gt;is what I am looking for in the first place*/
if SAS_Date=Prev_month then SAS_Date=.
if SAS_Date^=Prev_month and Prev_month=. then SAS_Date=.;
if SAS_Date^=Prev_month and  Prev_month^=. then SAS_Date= Sas_Date.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;&amp;nbsp;An example of what I mean by this is,&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;ID Jan2015&amp;nbsp; &amp;nbsp; Feb2015&amp;nbsp; &amp;nbsp;SAS_Date&amp;nbsp; Prev_month&lt;/DIV&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Feb2015&amp;nbsp; &amp;nbsp; &amp;nbsp; Jan2015&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;then the if statement that would be used in this example would be ;&lt;/DIV&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if feb2015^= jan2015 and jan2015^=. then feb2015=feb2015;&lt;/CODE&gt;&lt;/PRE&gt;giving&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;ID Jan2015&amp;nbsp; &amp;nbsp; Feb2015&lt;/DIV&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;&amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-footer"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 Apr 2018 19:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453715#M114682</guid>
      <dc:creator>Tommy1</dc:creator>
      <dc:date>2018-04-12T19:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453720#M114683</link>
      <description>&lt;P&gt;You could literally do what you want if you had a list of the variable names.&amp;nbsp; One version as a normal variable list and the other as a quoted string.&amp;nbsp; Note that this method has nothing to do with dates. Just picking the column before the one named in the input character variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input ID Jan2015 Feb2015 Mar2015 Apr2015 May2015 SAS_Date $ ;
cards;
1 1 1 2 5 . Feb2015
1 1 1 2 5 . Mar2015
1 1 1 2 5 . Apr2015
2 . 2 1 . 5 Mar2015
2 . 2 1 . 5 May2015
;

data tall ;
 set have ;
 array vals Jan2015 Feb2015 Mar2015 Apr2015 May2015 ;
 array names (5) $7 _temporary_ ('Jan2015' 'Feb2015' 'Mar2015' 'Apr2015' 'May2015' )  ;
 i=whichc(sas_date,of names(*));
 if i&amp;gt;0 then want=vals(i-1);
run;
proc transpose data=tall out=want(drop=_name_);
  by id ;
  id sas_date ;
  var want ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Apr 2018 19:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453720#M114683</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-12T19:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453737#M114690</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Here is another solution, that works&amp;nbsp;on actual data without the need to specify month variables in the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this version it expects the data to be as shown, i.e. the first variable is&amp;nbsp;a numeric ID variable, the last a sas-date, and all between are month variables. If real data is not like that, the code should be modified. Also, if more than one sas-date in an ID-group resolves to the same month, the code should be modified to make a summarization, where the out-variable is set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have; 
	ID = 1; Jan2015 = 1; Feb2015 = 2; Mar2015 = 3; SAS_date = '15feb2015'd; output; 
	ID = 1; Jan2015 = 1; Feb2015 = 2; Mar2015 = 3; SAS_date = '15mar2015'd; output; 
	ID = 1; Jan2015 = 1; Feb2015 = 2; Mar2015 = 3; SAS_date = '15jan2015'd; output; 
	ID = 2; Jan2015 = 1; Feb2015 = 2; Mar2015 = 3; SAS_date = '15feb2015'd; output; 
	ID = 3; Jan2015 = 1; Feb2015 = 2; Mar2015 = 3; SAS_date = '15jan2015'd; output; 
	ID = 3; Jan2015 = 1; Feb2015 = 2; Mar2015 = 3; SAS_date = '15mar2015'd; output; 
run;

* Set macro variable with number of months;
data _null_; set have (obs=1);
	array varin _numeric_;
	call symputx('monthcnt',dim(varin)-2);
run;
%put &amp;amp;=monthcnt;

* Works only if input data set is sorted on ID and a given SAS-date 
	(expressed as month) occurs only once within each ID group;
data want (drop=i SAS_date q1-q%eval(&amp;amp;monthcnt)); 
	set have; by ID;
	keep ID _numeric_;
	array in _numeric_;
	chk = put(SAS_date,monyy7.);

	* Declare tamp-array with retained variables to hold values for all
		records in ID group;
	array out q1-q%eval(&amp;amp;monthcnt);
	retain q1-q%eval(&amp;amp;monthcnt);

	* Set all months to missing in temp-array at start of each ID group;
	if first.ID then do i = 1 to &amp;amp;monthcnt; out{i} = .; end;
		
	* Transfer value for actual month to temp-array;
	do i = 1 to &amp;amp;monthcnt;
		a = vname(in{i+1});
		if upcase(vname(in{i+1})) = chk then out{i} = in{i+1};
	end;

	* Transfer values from temp_array to original variables and 
		output at end of each ID group;
	if last.ID then do;
		do i = 1 to &amp;amp;monthcnt; in{i+1} = out{i}; end;
		output;
	end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 19:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453737#M114690</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2018-04-12T19:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453745#M114692</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Thanks for the reply and for trying to help, this is very close to what I need. I have never used the whichc function before. When I run your code in your example I get&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ID&amp;nbsp; Feb2015&amp;nbsp; &amp;nbsp;Mar2015&amp;nbsp; &amp;nbsp;Apr2015&amp;nbsp; May2015&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This didn't really make sense to me because it is showing the value of the of the previous month when I need the value of the current month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;changed&amp;nbsp;the code&amp;nbsp;so that it was&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if i&amp;gt;0 then want=vals(i);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This seemed to work much better and corresponded to the to the values in the SAS_date column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ID&amp;nbsp; Feb2015&amp;nbsp; &amp;nbsp;Mar2015&amp;nbsp; &amp;nbsp;Apr2015&amp;nbsp; May2015&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;2&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Now the only thing I am still confused about this is that my last column is in fact a date and not a character value. How do I change it so that I would be able to work with a date column? Thanks so much for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 20:15:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453745#M114692</guid>
      <dc:creator>Tommy1</dc:creator>
      <dc:date>2018-04-12T20:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453759#M114694</link>
      <description>&lt;P&gt;It was picking the values from the previous month because that is what you said you wanted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get it to search for a date you could convert the date to a string using a format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;i=whichc(put(sasdate,monyy7.),of names(*));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Make sure to change the values used in the NAMES() array to match the values that MONYY. format generates.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know that your variables represent contiguous months then you might be able to generate the index using INTCK() function instead and just eliminate the NAMES array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; i=intck('month','01JAN2015'd,sas_date)+1;
 if 1 &amp;lt;= i &amp;lt;= dim(vals) then want=vals(i);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Apr 2018 20:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453759#M114694</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-12T20:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use date formats to reference columns in conditional statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453905#M114740</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12887"&gt;@ErikLund_Jensen&lt;/a&gt;&amp;nbsp;Thanks for the reply and for trying to help me out. Unfortunately, I was not able to figure out how generalize your code to my data.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;I spent a while very confused with the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Have data set because it wasn't the example that I provided, so I thought it was doing something different.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Thanks for the help, I was able to get your original code to work once I added in the SAS dates!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 13:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-date-formats-to-reference-columns-in-conditional/m-p/453905#M114740</guid>
      <dc:creator>Tommy1</dc:creator>
      <dc:date>2018-04-13T13:53:01Z</dc:date>
    </item>
  </channel>
</rss>

