BookmarkSubscribeRSS Feed

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;

9 REPLIES 9
stat_sas
Ammonite | Level 13

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;

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

stat_sas
Ammonite | Level 13

Does this happen after making changes in syntax?

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?

stat_sas
Ammonite | Level 13

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

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.

stat_sas
Ammonite | Level 13

What are you getting in age_term variable?

Reeza
Super User

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.

Hima
Obsidian | Level 7

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 4288 views
  • 0 likes
  • 4 in conversation