BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Arik
Fluorite | Level 6

Hi,

I'm trying to identify those people in my dataset, who died before their 80th birthday. I have their birthdate as well as the date of death. I tried to use the intnx function of SAS to compare the date of the 80th birthday and the date of death. Since I have a lot of entries in my dataset, I tried to reference the variable for the birthdate (geb_dat) instead of inserting the dates manually. However, I'm getting errors:

 

 

data mi_olink_CR;
	set dataset.mi_olink;
	if intnx('year', geb_dat, 80, 'same')> mort_dat then put 'died before 80th birthday';
run;

This produces the following log statement:

 

120  data mi_olink_CR;
121      set dataset.mi_olink;
122      if intnx('year', geb_dat, 80, 'same')> mort_dat then put 'died before 80th birthday';
                       -----------------
                       49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS
             release.  Inserting white space between a quoted string and the succeeding
             identifier is recommended.

123  run;

 

How do I have to reference the variable geb_dat (DATE9. Format)from the mi_olink_CR dataset in the intnx function?

Thanks!

Arik

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Looks to me like unbalanced quotes further up in the code.

This works:

data have;
input geb_dat :yymmdd10. mort_dat :yymmdd10.;
format geb_dat mort_dat yymmddd10.;
datalines;
1930-05-05 2011-04-03
1950-06-03 2012-05-04
;

data want;
set have;
if intnx('year', geb_dat, 80, 'same')> mort_dat then put 'died before 80th birthday';
run;

Log:

 73         data have;
 74         input geb_dat :yymmdd10. mort_dat :yymmdd10.;
 75         format geb_dat mort_dat yymmddd10.;
 76         datalines;
 
 NOTE: The data set WORK.HAVE has 2 observations and 2 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 79         ;
 80         
 81         
 82         data want;
 83         set have;
 84         if intnx('year', geb_dat, 80, 'same')> mort_dat then put 'died before 80th birthday';
 85         run;
 
 died before 80th birthday
 NOTE: There were 2 observations read from the data set WORK.HAVE.
 NOTE: The data set WORK.WANT has 2 observations and 2 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Looks to me like unbalanced quotes further up in the code.

This works:

data have;
input geb_dat :yymmdd10. mort_dat :yymmdd10.;
format geb_dat mort_dat yymmddd10.;
datalines;
1930-05-05 2011-04-03
1950-06-03 2012-05-04
;

data want;
set have;
if intnx('year', geb_dat, 80, 'same')> mort_dat then put 'died before 80th birthday';
run;

Log:

 73         data have;
 74         input geb_dat :yymmdd10. mort_dat :yymmdd10.;
 75         format geb_dat mort_dat yymmddd10.;
 76         datalines;
 
 NOTE: The data set WORK.HAVE has 2 observations and 2 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 79         ;
 80         
 81         
 82         data want;
 83         set have;
 84         if intnx('year', geb_dat, 80, 'same')> mort_dat then put 'died before 80th birthday';
 85         run;
 
 died before 80th birthday
 NOTE: There were 2 observations read from the data set WORK.HAVE.
 NOTE: The data set WORK.WANT has 2 observations and 2 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
Arik
Fluorite | Level 6
Thanks for your prompt reply!
Your code worked for me as well. Seems like I had a typo in the variable for birthdate.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 540 views
  • 3 likes
  • 2 in conversation