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
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
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
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.