<?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 how can i compute new variable? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396218#M66513</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* This is the STATS301 start up file */
*Set up title on line 1;
TITLE1 "STATS 301 / 749750841 / glee217 : &amp;amp;sysuserid";
*Specify SAS library for storing permanent SAS datasets;
LIBNAME stats301 "C:\301";

***HERE
***import .sas7bdat file;
data temp;
set stats301.account_level_ds;
run;


data nonnegative;
set temp;
keep current_balance lending_interest;
if (current_balance &amp;lt;0) then delete;
rename lending_interest=yearint;
yearint = (current_balance)*0.03;
run;

title1 "nonnegative";
proc print data=nonnegative (obs=10);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Hi I'm trying to create new variable called 'yearint' for data 'nonnegative' but somehow my code below doesn't work and it just gives me origianal 'lending_interest' value along to where it is not 'current_balance&amp;lt;0'&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;yearint = (current_balance)*0.03;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;how can i write down new variable and compute some new integer which is calculated with another variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Fri, 15 Sep 2017 09:14:26 GMT</pubDate>
    <dc:creator>glee217</dc:creator>
    <dc:date>2017-09-15T09:14:26Z</dc:date>
    <item>
      <title>how can i compute new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396218#M66513</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* This is the STATS301 start up file */
*Set up title on line 1;
TITLE1 "STATS 301 / 749750841 / glee217 : &amp;amp;sysuserid";
*Specify SAS library for storing permanent SAS datasets;
LIBNAME stats301 "C:\301";

***HERE
***import .sas7bdat file;
data temp;
set stats301.account_level_ds;
run;


data nonnegative;
set temp;
keep current_balance lending_interest;
if (current_balance &amp;lt;0) then delete;
rename lending_interest=yearint;
yearint = (current_balance)*0.03;
run;

title1 "nonnegative";
proc print data=nonnegative (obs=10);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Hi I'm trying to create new variable called 'yearint' for data 'nonnegative' but somehow my code below doesn't work and it just gives me origianal 'lending_interest' value along to where it is not 'current_balance&amp;lt;0'&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;yearint = (current_balance)*0.03;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;how can i write down new variable and compute some new integer which is calculated with another variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 09:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396218#M66513</guid>
      <dc:creator>glee217</dc:creator>
      <dc:date>2017-09-15T09:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: how can i compute new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396220#M66514</link>
      <description>&lt;P&gt;Your issue is likely the placement and use of rename - this is renaming another variable to be current balance. &amp;nbsp;This code below, renames the incoming variable, then your datasetp code will overwrite this.&lt;/P&gt;
&lt;P&gt;Note some formatting changes:&lt;/P&gt;
&lt;PRE&gt;title1 "STATS 301 / 749750841 / glee217 : &amp;amp;sysuserid";

libname stats301 "C:\301";

data nonnegative (keep=current_balance lending_interest);
  set stats301.account_level_ds (rename lending_interest=yearint);
  where current_balance &amp;lt; 0;
  yearint=(current_balance)*0.03;
run;

title1 "nonnegative";
proc print data=nonnegative (obs=10);
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Sep 2017 09:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396220#M66514</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-09-15T09:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: how can i compute new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396231#M66517</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data integer;
set temp;

if (current_balance &amp;lt;0) then yearint = lending_interest;

if (current_balance &amp;gt;=0) then yearint = int((current_balance)*0.03);
run;

proc print data=integer (obs=10);&lt;BR /&gt;var current_balance yearint
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;hi sorry but can i ask you a difference question? i still want to create variable 'yearint' but this time i want to use 'current_balance' variable directly. &amp;nbsp;And it didn't give me decimal places. do you know how to fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="캡처.JPG" style="width: 231px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15198i884B5B8BCF03D0C7/image-size/large?v=v2&amp;amp;px=999" role="button" title="캡처.JPG" alt="캡처.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 09:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396231#M66517</guid>
      <dc:creator>glee217</dc:creator>
      <dc:date>2017-09-15T09:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: how can i compute new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396278#M66518</link>
      <description>&lt;P&gt;You specify you want an integer result:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;current_balance &lt;SPAN class="token operator"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; yearint &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;int&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;current_balance&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0.03&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The int() is a function which returns only a hole number, remove that if you want decimals.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 11:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396278#M66518</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-09-15T11:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: how can i compute new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396370#M66524</link>
      <description>&lt;P&gt;You should ELSE IF instead of multiple IF and comment your code. It also seems weird to round one value and not the other for the same variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (current_balance &amp;lt;0) then yearint = lending_interest;
else if (current_balance &amp;gt;=0) then yearint = int((current_balance)*0.03);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159337"&gt;@glee217&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data integer;
set temp;

if (current_balance &amp;lt;0) then yearint = lending_interest;

if (current_balance &amp;gt;=0) then yearint = int((current_balance)*0.03);
run;

proc print data=integer (obs=10);&lt;BR /&gt;var current_balance yearint
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;hi sorry but can i ask you a difference question? i still want to create variable 'yearint' but this time i want to use 'current_balance' variable directly. &amp;nbsp;And it didn't give me decimal places. do you know how to fix this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="캡처.JPG" style="width: 231px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15198i884B5B8BCF03D0C7/image-size/large?v=v2&amp;amp;px=999" role="button" title="캡처.JPG" alt="캡처.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 14:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-compute-new-variable/m-p/396370#M66524</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-15T14:55:26Z</dc:date>
    </item>
  </channel>
</rss>

