data=studypop; set=b; *variable for emigration*; if MTYP=:'E' then EM=1; else EM=0; mig_year= (SUBSTR(MDATUM,1,4)); mig_year_num =input(mig_year,4.); age_mig=(mig_year_num-bfodar); *variable death*; bfoddat_SAS = input( put(X_bfoddat,8.), YYMMDD8.); dodsdatum_SAS= input (put(X_dodsdatum, 8.),YYMMDD8.); if dodsdatum_SAS ne . then age_dod=INT(YRDIF(bfoddat_SAS,dodsdatum_SAS,'actual')); * age when subject recived ADHD-diagnosis*; datum_ADHD_SAS = input( put(datum_adhd,8.), YYMMDD8.); if datum_ADHD_SAS ne . then age_diag=INT(YRDIF(bfoddat_SAS,datum_ADHD_SAS,'actual')); *age when subject got stimulant prescription *; FDATUM_ADLM_sas = input( put(FDATUM_ADLM,8.), YYMMDD8.); if FDATUM_ADLM_sas ne . then age_LM=INT(YRDIF(bfoddat_SAS,FDATUM_ADLM_sas,'actual')); *age at end of follow-up*; enddate=MDY(12,31,2013); age= INT(YRDIF(bfoddat_SAS,enddate,'actual')); /*variable for age when reciving ADHD-diagnosis AND/OR age when reciving stimulant prescription*/ Age_adhd = age_LM OR age_diag; /* Variable for age at exit (time_var) */ time_var=min(age_adhd, age_mig, age_dod,age); /* If a child has emigrated and then immigrated again, it might have an ADHD diagnosis that happens after age at exit. This is recoded as no ADHD, since the ADHD happens after end of follow-up for that child. */ if age_ADHD > time_var then ADHDD=0; /* Exclude children with an ADHD diagnosis before 3 years of age */ if .< age_ADHD < 3 then delete; /* Define age at entry, which is 3 years */ age_entry=3; run; proc phreg data=studypop; class CH_ICD_CAT (ref='4'); model time_var*ADHDD(0) = CH_ICD_CAT /RL entrytime=Age_entry; ods output ParameterEstimates = estimates CensoredSummary = censored;
I am having issues with running these codes. All my observations go missing.
NOTE: There were 3445229 observations read from the data set WORK.B.
NOTE: The data set WORK.STUDYPOP has 0 observations and 247 variables.
I think the issue is due to me defining age_ADHD incorrectly.
I want it definied as: age when reciving diagnosis and/or age when reciving stimulat prescription.
what am i doing wrong?
data=studypop;
set=b;
This can't be correct. There should be no equal signs in these statements.
However ... please, in this case (and in all cases in the future), if there is a problem in the log, show us the ENTIRE log for this segment of code, every single line in the log for this segment of code, so we can see the code as it appears in the log, along with the NOTEs, WARNINGs and ERRORs. Please do NOT show us parts of the log disconnected from the code in the log.
When you show us the log, please maintain the formatting of the log, by copying it as text and pasting it into the window that appears when you click on the </> icon here in the SAS Communities. DO NOT SKIP THIS STEP.
data studypop;
set b;
*variable for emigration*;
if MTYP=:'E' then EM=1;
else EM=0;
mig_year= (SUBSTR(MDATUM,1,4));
mig_year_num =input(mig_year,4.);
age_mig=(mig_year_num-bfodar);
*variable death*;
bfoddat_SAS = input( put(X_bfoddat,8.), YYMMDD8.);
dodsdatum_SAS= input (put(X_dodsdatum, 8.),YYMMDD8.);
if dodsdatum_SAS ne . then age_dod=INT(YRDIF(bfoddat_SAS,dodsdatum_SAS,'actual'));
* age when subject recived ADHD-diagnosis*;
datum_ADHD_SAS = input( put(datum_adhd,8.), YYMMDD8.);
if datum_ADHD_SAS ne . then age_diag=INT(YRDIF(bfoddat_SAS,datum_ADHD_SAS,'actual'));
*age when subject got stimulant prescription *;
FDATUM_ADLM_sas = input( put(FDATUM_ADLM,8.), YYMMDD8.);
if FDATUM_ADLM_sas ne . then age_LM=INT(YRDIF(bfoddat_SAS,FDATUM_ADLM_sas,'actual'));
*age at end of follow-up*;
enddate=MDY(12,31,2013);
age= INT(YRDIF(bfoddat_SAS,enddate,'actual'));
run;
data ADHD;
set studypop;
/*variable for age when reciving ADHD-diagnosis AND/OR age when reciving stimulant prescription*/
Age_adhd = (age_LM OR age_diag);
/* Variable for age at exit (time_var) */
time_var=min(age_adhd, age_mig, age_dod,age);
/* If a child has emigrated and then immigrated again, it might have an ADHD diagnosis that happens after age at exit.
This is recoded as no ADHD, since the ADHD happens after end of follow-up for that child. */
if age_ADHD > time_var then ADHDD=0;
/* Exclude children with an ADHD diagnosis before 3 years of age */
if 0< age_ADHD < 3 then delete;
/* Define age at entry, which is 3 years */
age_entry=3;
run;
proc phreg data=adhd;
class CH_ICD_CAT (ref='4');
model time_var*ADHDD(0) = CH_ICD_CAT /RL entrytime=Age_entry;
ods output ParameterEstimates = estimates CensoredSummary = censored;
run;
382 data ADHD ;
383 set studypop;
384
385 age_ADHD=(age_LM OR AGE_DIAG);
386
387 /* Variable for age at exit (time_var) */
388 time_var=min(age_adhd, age_mig, age_dod,age);
389
390 /* If a child has emigrated and then immigrated again, it might have an ADHD diagnosis
390! that happens after age at exit.
391 This is recoded as no ADHD, since the ADHD happens after end of follow-up for that child.
391! */
392 if age_ADHD > time_var then ADHDD=0;
393
394 /* Exclude children with an ADHD diagnosis before 3 years of age */
395 if 0< age_ADHD < 3 then delete;
396
397 /* Define age at entry, which is 3 years */
398 age_entry=3;
399
400 run;
NOTE: There were 2863330 observations read from the data set WORK.STUDYPOP.
NOTE: The data set WORK.ADHD has 2767319 observations and 247 variables.
NOTE: DATA statement used (Total process time):
real time 9.03 seconds
cpu time 5.23 seconds
401
402 proc phreg data=adhd;
403 class CH_ICD_CAT (ref='4');
404 model time_var*ADHDD(0) = CH_ICD_CAT /RL entrytime=Age_entry;
405 ods output ParameterEstimates = estimates CensoredSummary = censored;
406 run;
NOTE: 2767319 observations were deleted due either to missing or invalid values for the entry,
time, censoring, frequency, offset or explanatory variables or to invalid operations in
generating the values for some of the explanatory variables.
ERROR: There are no valid observations for the analysis.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PHREG used (Total process time):
real time 4.29 seconds
cpu time 4.29 seconds
WARNING: Output 'CensoredSummary' was not created. Make sure that the output object name,
label, or path is spelled correctly. Also, verify that the appropriate procedure
options are used to produce the requested output object. For example, verify that
the NOPRINT option is not used.
WARNING: Output 'ParameterEstimates' was not created. Make sure that the output object name,
label, or path is spelled correctly. Also, verify that the appropriate procedure
options are used to produce the requested output object. For example, verify that
the NOPRINT option is not used.
I am sorry for not being clear enough. This is the log statement that i recived when running the code.
Hello,
Have you already taken a close look at ADHD data set which is the ABT (Analytical Base Table) for your analysis?
You can do a VT (ViewTable) or double click the dataset to browse it.
I think it will become clear which variable is causing problems.
Koen
NOTE: 2767319 observations were deleted due either to missing or invalid values for the entry, time, censoring, frequency, offset or explanatory variables or to invalid operations in generating the values for some of the explanatory variables. ERROR: There are no valid observations for the analysis.
This is a different message than in your original post.
This message means, most likely, that you have a variable in the model for PROC PHREG that is always missing. Look at your data to see what is in there.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.