Adding (+) 2 numeric variables together

Reply
Frequent Contributor
Posts: 142

Adding (+) 2 numeric variables together

The final statement im trying to add 'Age' plus 'Year but It doesnt work, I just get a a full stop, anyone know why my code wont add the 2 variable, both numeric?

I have had to create 'Customer age profile' to obtain the 'Age' and a second statement 'Term years to get the 'Year'. Im then joining the 2 tables to create the third statement 'Add age and year'.

/*Customer Age Profile*/

proc sql;
create table work.borrower_age as
select
AccountNo as accnum,
int(yrdif(DATE_OF_BIRTH,today(),'ACTUAL')) as Age

from
green.optimum201302;

quit;

/*Term Years*/

proc sql;
create table work.term_years as
select
distinct month_date,
accnum,
round(remaining_term_months/12,1) as year

from work.dataset_basel;

quit;

/*Add Age and Year*/

proc sql;
  create table work.age_at_term as
  select
  b.month_date,
  a.accnum,
  a.age + b.year as age_term

  from
  work.borrower_age as a
  left join work.term_years as b
  on a.accnum = b.accnum;

quit;

Trusted Advisor
Posts: 1,228

Re: Adding (+) 2 numeric variables together

Try this.

proc sql;
  create table work.age_at_term as
  select
  b.month_date,
  a.accnum,
  sum(a.age, b.year,0) as age_term

  from
  work.borrower_age as a
  left join work.term_years as b
  on a.accnum = b.accnum;

quit;

Frequent Contributor
Posts: 142

Re: Adding (+) 2 numeric variables together

That seems to work on the adding the 2 variables thanks, but now month_date shows just a full stop now?

Trusted Advisor
Posts: 1,228

Re: Adding (+) 2 numeric variables together

Does this happen after making changes in syntax?

Frequent Contributor
Posts: 142

Re: Adding (+) 2 numeric variables together

I have just tested it and it appears to have the full stop before the syntax change, any reason as to why this might be?

Trusted Advisor
Posts: 1,228

Re: Adding (+) 2 numeric variables together

Not sure about your data structure. I would suggest check your source tables to validate this.

Frequent Contributor
Posts: 142

Re: Adding (+) 2 numeric variables together

Ive just been sampling the data and the year and age isn't adding up either. I didn't check it correctly in the first instance sorry so im still requiring help on this.

Trusted Advisor
Posts: 1,228

Re: Adding (+) 2 numeric variables together

What are you getting in age_term variable?

Super User
Posts: 18,997

Re: Adding (+) 2 numeric variables together

You have to provide more info for us to tell you why something doesn't work, specifically how isn't it correct.

If you can replicate the problem with fake data and post the fake data and code here.

Regular Contributor
Posts: 233

Re: Adding (+) 2 numeric variables together

It would be easy to get a solution if you give use the data what you have and what you want. With out ooking at the data, its not that easy to solve.

Ask a Question
Discussion stats
  • 9 replies
  • 287 views
  • 0 likes
  • 4 in conversation