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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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