BookmarkSubscribeRSS Feed
RiverDancer
Calcite | Level 5

Hello. I am new to SAS Enterprise Guide. I need help with error messages. I have added a PERS table for the date of birth and need to calculate the age.   

 

The original code: 

Original Code - WorkedOriginal Code - Worked

 

proc sql;

   create table case_pgm_ac as

   select distinct

             t1.case_name,

          t1.id label="case_id" as case_id,

          t1.serial_num_identif as caseno,

             t2.id as pgm_id,

          t2.pgm_code,

          t3.stat_rsn_code,

          t3.stat_code as pgm_stat,

          t3.beg_date as pgm_beg_date,

          t3.end_date as pgm_end_date,

          t3.id as pgmdetlid

      from CalSAWS.case as t1

           left join CalSAWS.pgm as t2 on t1.id=t2.case_id

           left join CalSAWS.pgm_detl t3 on t2.id=t3.pgm_id

      where t1.serial_num_identif = '2221489'

       and t1.county_code="33"

           and t2.pgm_code in ('WT')

           and t3.stat_code='AC'

         and t3.beg_date <'01nov2020'd and t3.end_date >= '01oct2020'd

order by t1.id,t2.id,t3.beg_date desc,t3.end_date desc;

quit;

 

 

The Edit code to include Members from February 2024, and calculate their age. I added Table 6- DOB- Date of Birth and tried to calculate Age.

Edited Code DOB - ErrorsEdited Code DOB - Errors

 

proc sql;

   create table case_pgm_pers_detl_ac as

   select distinct

             t1.case_name,

          t1.id label="case_id" as case_id,

          t1.serial_num_identif,

     t2.id as pgmid,

          t2.pgm_code,

     t3.id as pgmdetlid,

          t3.stat_rsn_code,

          t3.stat_code as pgm_stat,

          t3.beg_date as pgm_beg_date,

          t3.end_date as pgm_end_date,

          t4.id as pgmpersid,

 

             t5.id as pers_detl_id,

             t5.stat_code as pers_stat,

             t5.role_code,

             t5.beg_date as pers_beg_date,

             t5.end_date as pers_end_date,

             t6.id as pers,

             t6.dob as dateofbirth,

             datepart(t6.dob) as dateofbirth format=date9., 

 

     from CalSAWS.case as t1

           left join CalSAWS.pgm t2 on t1.id=t2.case_id

           left join CalSAWS.pgm_detl t3 on t2.id=t3.pgm_id

           left join CalSAWS.pgm_pers t4 on t2.id=t4.pgm_id

           left join CalSAWS.pgm_pers_detl t5 on t4.id=t5.pgm_pers_id

           left join CalSAWS.pers t6 on t4.id=t5.pgm_pers_id

 

     where t1.serial_num_identif

           and t2.pgm_code='FS'

           and t3.stat_code='AC'

           and t5.stat_code='AC'

           and t5.role_code='ME'

         and t3.beg_date <'01apr2024'd and t3.end_date >= '01mar2024'd

     and t5.beg_date<'01apr2024'd and t5.end_date>='01mar2024'd

           and pgm_detl.end_date >= pgm_pers_detl.beg_date

and pgm_detl.beg_date <= pgm_pers_detl.end_date

and int((today()-Birth_Date)/365.25) as Age;

quit;

 

 

Tables Used

TablesTables

1 REPLY 1
rudfaden
Lapis Lazuli | Level 10
You have a comme on the last line before FROM. That should not be there.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 309 views
  • 0 likes
  • 2 in conversation