<?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 conditional values based on column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440910#M110232</link>
    <description>&lt;P&gt;I currently have data regarding income streams over four years, the income stream fills a 4x4 matrix as follows:&lt;/P&gt;&lt;PRE class="lang-sql prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;        Year1   Year2   Year3   Year4

&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2017&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;10&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;15&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;20&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;25&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2018&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;10&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;15&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;20&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;25&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2019&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;10&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;15&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;20&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;25&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2020&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;10&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;15&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;20&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;25&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The income streams come from a debt instrument where the rows indicate when the debt was issued and the columns indicate the flow of income coming in per year.&lt;/P&gt;&lt;P&gt;I am trying to build another matrix to highlight whether or not the debt instrument was priced that year to create this matrix:&lt;/P&gt;&lt;PRE class="lang-sql prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;    Year1   Year2   Year3   Year4&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2017&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2018&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2019&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2020&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is a very simple example and it goes on to work on how often the instrument is repriced etc. for simplicity, is there a way to create an if or where function that returns a 1 or 0 depending on whether the year is equal to or within a certain amount of time of the instrument being issued.&lt;/P&gt;&lt;P&gt;So far i'm thinking along the lines&lt;/P&gt;&lt;PRE class="lang-sql prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pun"&gt;%&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;Repricing &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;data want&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="kwd"&gt;set&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; have&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="kwd"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; Year&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;i&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;Repricing&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt; 
    &lt;SPAN class="kwd"&gt;then&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; Year&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;i&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;    run&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It's probably obvious that SAS isn't my language of choice, TIA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess another way to look at this would be to allocate:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*repricing is in months;
%Repricing = 24;

*translate months to year;

data want;
set have;

if column_header ^=1
then return 1;
else if column_header &amp;lt;1 or &amp;gt;1
then return 0;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Feb 2018 15:16:57 GMT</pubDate>
    <dc:creator>89974114</dc:creator>
    <dc:date>2018-02-28T15:16:57Z</dc:date>
    <item>
      <title>conditional values based on column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440910#M110232</link>
      <description>&lt;P&gt;I currently have data regarding income streams over four years, the income stream fills a 4x4 matrix as follows:&lt;/P&gt;&lt;PRE class="lang-sql prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;        Year1   Year2   Year3   Year4

&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2017&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;10&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;15&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;20&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;25&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2018&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;10&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;15&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;20&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;25&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2019&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;10&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;15&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;20&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;25&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2020&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;10&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;15&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;20&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;25&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The income streams come from a debt instrument where the rows indicate when the debt was issued and the columns indicate the flow of income coming in per year.&lt;/P&gt;&lt;P&gt;I am trying to build another matrix to highlight whether or not the debt instrument was priced that year to create this matrix:&lt;/P&gt;&lt;PRE class="lang-sql prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;    Year1   Year2   Year3   Year4&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2017&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2018&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2019&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2020&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;       &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is a very simple example and it goes on to work on how often the instrument is repriced etc. for simplicity, is there a way to create an if or where function that returns a 1 or 0 depending on whether the year is equal to or within a certain amount of time of the instrument being issued.&lt;/P&gt;&lt;P&gt;So far i'm thinking along the lines&lt;/P&gt;&lt;PRE class="lang-sql prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pun"&gt;%&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;Repricing &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;data want&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="kwd"&gt;set&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; have&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="kwd"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; Year&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;i&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;Repricing&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt; 
    &lt;SPAN class="kwd"&gt;then&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; Year&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;i&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;    run&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It's probably obvious that SAS isn't my language of choice, TIA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess another way to look at this would be to allocate:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*repricing is in months;
%Repricing = 24;

*translate months to year;

data want;
set have;

if column_header ^=1
then return 1;
else if column_header &amp;lt;1 or &amp;gt;1
then return 0;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 15:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440910#M110232</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-02-28T15:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: conditional values based on column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440961#M110247</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;is there a way to create an if or where function that returns a 1 or 0 depending on whether the year is equal to or within a certain amount of time of the instrument being issued.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no idea what that means or how it works as a decision rule.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 17:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440961#M110247</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2018-02-28T17:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: conditional values based on column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440965#M110249</link>
      <description>&lt;P&gt;I'll create a false scenario, imagine it is 31/12/2016 so&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let date=31/12/2016;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;imagine that this debt instrument is repriced only when it is issued (fixed asset)&lt;/P&gt;&lt;P&gt;the table displays&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Row(1-4): when the debt instrument expires&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column (1-4): the payments made by the debt instrument.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Every time the debt instrument expires, it has to be replaced immediately and is re-priced (A 1 is flagged)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i'm looking to make a dataset where you check whether or not the debt instrument is expiring and I wish to flag a 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So example a debt instrument expires in 2017 , so flag 2017,2017 row,column&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expire 2018 - flag 18,18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this case means a diagonal matrix of 1's and 0 everywhere else&lt;/P&gt;&lt;P&gt;So far this code has worked for the example but it could get difficult for maturity / repricing events other than just 1 year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

*arrays for years and flags;
array _year(2017:2020) year2017-year2020;
array _flag(2017:2020) flag2017-flag2020;

*loop over array;
do i=2017 to hbound(_year);
    /*check if year matches year in variable name*/
    if put(yearD, 4.) = compress(vname(_year(i)),, 'kd') 
        then _flag(i)=1;
    else _flag(i)=0;
end;

drop i;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 17:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440965#M110249</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-02-28T17:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: conditional values based on column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440969#M110251</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;it could get difficult for maturity / repricing events other than just 1 year.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do we know when a debt instrument is going to expire?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your original example, Year one is 2018. Year&amp;nbsp; 2 is 2019, etc.&amp;nbsp; 17's expire in 18.&amp;nbsp; 18's expire in 19.&amp;nbsp; How do we know that other than just knowing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 17:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440969#M110251</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2018-02-28T17:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: conditional values based on column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440971#M110252</link>
      <description>&lt;P&gt;I guess the only way to really know is by introducing a macro variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%Repricingperiod = 'Insert Years or Months Here';&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 17:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440971#M110252</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-02-28T17:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: conditional values based on column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440976#M110257</link>
      <description>&lt;P&gt;I'm starting to think an interactive long macro in this sort of idea&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let initialyear= 'insert initial year here';&lt;/P&gt;&lt;P&gt;%let repricingfrequency= 'Insert repricing in years here';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we make the first column ID = _N_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then ID=ID+&amp;nbsp;&amp;amp;initialyear +&amp;nbsp;&amp;amp;repricingfrequency;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then take that code that I posted where you flag up on the new dataset when&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID = Column header.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will give this a go tomorrow in arrays when i'm less tired&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 18:02:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-values-based-on-column/m-p/440976#M110257</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-02-28T18:02:52Z</dc:date>
    </item>
  </channel>
</rss>

