BookmarkSubscribeRSS Feed
manthan
Fluorite | Level 6

Hello all, 

 

doing a study on antibiotics and hypoglycemia. I am pasting my code below for SAS. 

 

I was doing great and had no errors, until the very last step of logistic regression analysis: I get the following error there: 

ERROR: There are no valid observations.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 128052 observations read from the data set WORK.DATA5.
 
Why am I getting no valid observations? for this step when there are 128052 observations read.. also I am able to get frequencies etc without any issues.. someone please help.. I am trying to get the odds ratios and its giving me an error at the very last step.....
 
I post the code below:
 
proc import DATAFILE="/home/u50297477/2014-2020.xlsx" 
            OUT=data DBMS=XLSX 
   REPLACE;
run;
 
data data2(rename=(patientage=patientage1 weightofpatient=weightofpatient1 
bmi=bmi1 glucosevalue=glucosevalue1 dayofhospital=dayofhospital1 
highestglucose=highestglucose1 lowestglucose=lowestglucose1));
 
set work.import;
 
if mrn="MRN" then
delete;
run;
 
data data3(drop=patientage1 weightofpatient1 bmi1 glucosevalue1 dayofhospital1 
highestglucose1 lowestglucose1);
set data2;
 
patientage=input(patientage1, best.);
WeightOfPatient=input(WeightOfPatient1, best.);
BMI=input(BMI1, best.);
GlucoseValue=input(GlucoseValue1, best.);
DayOfHospital=input(DayOfHospital1, best.);
HighestGlucose=input(HighestGlucose1, best.);
LowestGlucose=input(LowestGlucose1, best.);
run;
 
*Subset based on age;
 
data data4;
set data3;
where (18 <=patientage <=80);
run;
 
*verify;
 
/*
proc means data = data4 maxdec=0;
var patientage;
run;
*/
 
data data5;
set data4;
 
only_date=datepart(AdmitDtm);
month_part=month(only_date);
year_part=year(only_date);
hour_part=hour(AdmitDTM);
 
format only_date date9.;
 
run;
 
 
data data5;
set data5;
 
if 0<=hour_part<=6 then
Timeofday=0;
else if 7<=hour_part<=12 then
Timeofday=1;
else if hour_part > 12 then
Timeofday=2;
 
if GenderCode='M' then
Sex=1;
else
Sex=0;
 
 
if RaceCode='Black/African Americ' then Race=1;
else if RaceCode='White' then Race=2;
else if RaceCode='Asian Indian' then Race=3;
    else if RaceCode='Chinese' then Race=4;
    else if RaceCode='Other Race' then Race=5;
    else Race = 0;
run;
 
 
 
data data5;
set data5;
 
if PregnantYN in ("No","Not applicable","Unknown","") then Pregnant = 0;
else if PregnantYN = "Yes" then Pregnant = 1;
 
if 0<=BMI<=18.50 then BodyMassIndex=0;
else if 18.51<=BMI<=25.00 then BodyMassIndex=1;
else if 25.01<=BMI<=30.00 then BodyMassIndex=2;
else if BMI>30.01 then BodyMassIndex=3;
 
if 18<=PatientAge<=65 then Age=0;
else if 66<=PatientAge<=75 then Age=1;
else if PatientAge>75 then Age=2;
 
if BasalInsulin='Yes' OR ShortActingInsulin='Yes' OR PremixInsulin='Yes' then Insulin=1;
 
if BasalInsulin='No' AND ShortActingInsulin='No' AND PremixInsulin='No' then Insulin=0;
 
if OnSulfonylurea='Yes' then Sulfonylurea=1;
else Sulfonylurea=0;
 
if On_Prandin='Yes' then Prandin=1;
else Prandin=0;
 
if On_Empagliflozin='Yes' OR On_Dapagliflozin='Yes' then SGLT2=1;
 
if On_Empagliflozin='No' AND On_Dapagliflozin='No' then SGLT2=0;
 
if On_Metformin='Yes' then Metformin=1;
else Metformin=0;
 
if On_Sitagliptin='Yes' then DPP4=1;
else DPP4=0;
 
run;
 
 
 
 
 
/*Correct messy date columns*/
 
data data5(drop=   ErtapenemStartDate BactrimStartDate   LinezolidStartDate PiperacillinStartDate CephalexinStartDate 
                   MeropenemStartDate ClindamycinStartDate AmoxicillinStartDate CeftriaxoneStartDate AzithromycinStartDate
                   LevofloxacinStartDate CiprofloxacinStartDate VancomycinStartDate MetronidazoleStartDate AmpicillinStartDate
                   CefepimeStartDate UnasynStartDate GentamicinStartDate CefazolinStartDate DaptomycinStartDate);
  set data5;
  
  if ErtapenemStartDate ne "" and length(strip(ErtapenemStartDate)) < 10 then x1 = input(ErtapenemStartDate, best.);
  if BactrimStartDate ne "" and length(strip(BactrimStartDate)) < 10 then x2 = input(BactrimStartDate, best.);
  if LinezolidStartDate ne "" and length(strip(LinezolidStartDate)) < 10 then x3 = input(LinezolidStartDate, best.);
  if PiperacillinStartDate ne "" and length(strip(PiperacillinStartDate)) < 10 then x4 = input(PiperacillinStartDate, best.);
  if CephalexinStartDate ne "" and length(strip(CephalexinStartDate)) < 10 then x5 = input(CephalexinStartDate, best.);
  if MeropenemStartDate ne "" and length(strip(MeropenemStartDate)) < 10 then x6 = input(MeropenemStartDate, best.);
  if ClindamycinStartDate ne "" and length(strip(ClindamycinStartDate)) < 10 then x7 = input(ClindamycinStartDate, best.);
  if AmoxicillinStartDate ne "" and length(strip(AmoxicillinStartDate)) < 10 then x8 = input(AmoxicillinStartDate, best.);
  if CeftriaxoneStartDate ne "" and length(strip(CeftriaxoneStartDate)) < 10 then x9 = input(CeftriaxoneStartDate, best.);
  if AzithromycinStartDate ne "" and length(strip(AzithromycinStartDate)) < 10 then x10 = input(AzithromycinStartDate, best.);
  if LevofloxacinStartDate ne "" and length(strip(LevofloxacinStartDate)) < 10 then x11 = input(LevofloxacinStartDate, best.);
  if CiprofloxacinStartDate ne "" and length(strip(CiprofloxacinStartDate)) < 10 then x12 = input(CiprofloxacinStartDate, best.);
  if VancomycinStartDate ne "" and length(strip(VancomycinStartDate)) < 10 then x13 = input(VancomycinStartDate, best.);
  if MetronidazoleStartDate ne "" and length(strip(MetronidazoleStartDate)) < 10 then x14 = input(MetronidazoleStartDate, best.);
  if AmpicillinStartDate ne "" and length(strip(AmpicillinStartDate)) < 10 then x15 = input(AmpicillinStartDate, best.);
  if CefepimeStartDate ne "" and length(strip(CefepimeStartDate)) < 10 then x16 = input(CefepimeStartDate, best.);
  if UnasynStartDate ne "" and length(strip(UnasynStartDate)) < 10 then x17 = input(UnasynStartDate, best.);
  if GentamicinStartDate ne "" and length(strip(GentamicinStartDate)) < 10 then x18 = input(GentamicinStartDate, best.);
  if CefazolinStartDate ne "" and length(strip(CefazolinStartDate)) < 10 then x19 = input(CefazolinStartDate, best.);
  if DaptomycinStartDate ne "" and length(strip(DaptomycinStartDate)) < 10 then x20 = input(DaptomycinStartDate, best.);
  
run;
 
data data5;
  set data5;
             
  rename x1 = ErtapenemStartDate x2 = BactrimStartDate x3 = LinezolidStartDate x4 = PiperacillinStartDate x5 = CephalexinStartDate
         x6 = MeropenemStartDate x7 = ClindamycinStartDate x8 = AmoxicillinStartDate x9 = CeftriaxoneStartDate x10 = AzithromycinStartDate
         x11 = LevofloxacinStartDate x12 = CiprofloxacinStartDate x13 = VancomycinStartDate x14 = MetronidazoleStartDate x15 = AmpicillinStartDate
         x16 = CefepimeStartDate x17 = UnasynStartDate x18 = GentamicinStartDate x19 = CefazolinStartDate x20 = DaptomycinStartDate;
run;
 
/*Create dummy variables based on these date columns*/
 
data data5;
  set data5;
  
  
  array dates{20} BactrimStartDate ErtapenemStartDate LinezolidStartDate PiperacillinStartDate CephalexinStartDate 
                  MeropenemStartDate ClindamycinStartDate AmoxicillinStartDate CeftriaxoneStartDate AzithromycinStartDate
                  LevofloxacinStartDate CiprofloxacinStartDate VancomycinStartDate MetronidazoleStartDate AmpicillinStartDate
                  CefepimeStartDate UnasynStartDate GentamicinStartDate CefazolinStartDate DaptomycinStartDate;
                  
  array dummy{20} Bactrim Ertapenem  Linezolid Piperacillin Cephalexin Meropenem Clindamycin Amoxicillin Ceftriaxone Azithromycin
                  Levofloxacin Ciprofloxacin Vancomycin Metronidazole Ampicillin Cefepime Unasyn Gentamicin Cefazolin Daptomycin;
  
  do i = 1 to dim(dates);
  
    if .< dates{i} < dayofhospital then dummy{i} = 1;
    else dummy{i} = 0;
  end;
  
  if find(On_antibiotic, 'Doxycycline')>0 then Doxycycline=1;
  else Doxycycline=0;
run;
 
 
 
data data5;
set data5;
 
if 0<=GlucoseValue<=69 then Hypoglycemia=1;
else if glucoseValue=> 70 then Hypoglycemia=0;
 
if 55<=GlucoseValue<=69 then ClassHypoglycemia=1;
else if 0<=glucoseValue<=54 then ClassHypoglycemia=2;
else if Glucosevalue=>70 then ClassHypoglycemia=0;
run;
 
 
data data5;
set data5;
 
array cols{20} Bactrim Ertapenem  Linezolid Piperacillin Cephalexin Meropenem Clindamycin Amoxicillin Ceftriaxone Azithromycin
                  Levofloxacin Ciprofloxacin Vancomycin Metronidazole Ampicillin Cefepime Unasyn Gentamicin Cefazolin Daptomycin;
                  
    do i=1 to dim(cols);
      if cols{i} = 1 or Doxycycline = 1 then Antiibiotic = 1;
      else if cols{i} = 0 then Antiibiotic = 0;
    end;
Run;
 
 
data data5;
set data5;
 
if TubeFeed='Yes' then TF=1;
else TF=0;
 
if Regular='Yes' then Diet=1;
else Diet=0;
 
if Bactrim=1 OR Amoxicillin=1 OR Cephalexin=1 then OralAntibiotic=1;
else OralAntibiotic=0;
 
run;
 
 
data data5;
set data5;
 
if Metronidazole=1 then nitroimidazole=1;
else nitroimidazole=0;
 
if Levofloxacin=1 OR Ciprofloxacin=1 then Floroquinolone=1;
else Floroquinolone=0;
 
if Clindamycin=1 then Lincosamide=1;
else Lincosamide=0;
 
if Doxycycline=1 then Tetracycline=1;
else Tetracycline=0;
 
if Vancomycin=1 then Glycopeptide=1;
else Glycopeptide=0;
 
if Daptomycin=1 then Lipopeptide=1;
else lipopeptide=0;
 
if Azithromycin=1 then Macrolide=1;
else Macrolide=0;
 
if Bactrim=1 then Sulfonamides=1;
else Sulfonamides=0;
 
if Gentamicin=1 then Aminoglycosides=1;
else Aminoglycosides=0;
 
if Cephalexin=1 OR Ceftriaxone=1 OR Cefepime=1 OR Cefazolin=1 OR Cefepime=1 then Cephalosporin=1;
else Cephalosporin=0;
 
if Piperacillin=1 OR Amoxicillin=1 OR Ampicillin=1 OR Unasyn=1 then Penicillin=1;
else if Piperacillin=0 OR Amoxicillin=0 OR Ampicillin=0 OR Unasyn=0 then Penicillin=0;
 
if Ertapenem=1 OR Meropenem=1 then Carbapenem=1;
else Carbapenem=0;
run;
 
proc freq data=data5;
tables hypoglycemia*Antiibiotic;
run;
 
data data5;
  set data5;
  
  where Pneumonia in ("No","Yes");
run;
 
proc logistic data= data5 descending;
class race (ref="0") RenalDisease (ref="No") HistoryOfDiabetes (ref="No") SGLT2 (ref="0")  
BodyMassIndex (ref="0") sex (ref="0") Insulin (ref="0") Prandin (ref="0") 
Metformin (ref="0") Sulfonylurea (ref="0")      
   Diet (ref="0") TPN (ref="No") Age (ref="0")     
   sepsis  (ref="No") Pneumonia (ref="No") UTI (ref="No") 
Cellulitis (Ref="No");
Model hypoglycemia=antiibiotic race sex BodymassIndex DayofHospital 
HistoryofDiabetes RenalDisease Insulin Prandin Metformin SGLT2 Sulfonylurea Diet TPN Age  Sepsis Pneumonia 
UTI Cellulitis;
run;
4 REPLIES 4
PaigeMiller
Diamond | Level 26

When you get an error in the log, SHOW US the log for this step. That is, the log from where it says PROC LOGISTIC all the way down to the last NOTE after PROC LOGISTIC.

 

There are no valid observations ... usually means you need to look at the data with your own eyes and see what is in there. You will probably find that every observation has a missing value somewhere, and that your data set used by PROC LOGISTIC was not created properly.

--
Paige Miller
manthan
Fluorite | Level 6

here you are : log :

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 proc logistic data= data5 descending;
70 class race (ref="0") RenalDisease (ref="No") HistoryOfDiabetes (ref="No") SGLT2 (ref="0")
71 BodyMassIndex (ref="0") sex (ref="0") Insulin (ref="0") Prandin (ref="0")
72 Metformin (ref="0") Sulfonylurea (ref="0")
73 Diet (ref="0") TPN (ref="No") Age (ref="0")
74 sepsis (ref="No") Pneumonia (ref="No") UTI (ref="No")
75 Cellulitis (Ref="No");
76 Model hypoglycemia=antiibiotic race sex BodymassIndex DayofHospital
77 HistoryofDiabetes RenalDisease Insulin Prandin Metformin SGLT2 Sulfonylurea Diet TPN Age Sepsis Pneumonia
78 UTI Cellulitis;
79 run;
 
ERROR: There are no valid observations.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 128052 observations read from the data set WORK.DATA5.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.19 seconds
user cpu time 0.11 seconds
system cpu time 0.09 seconds
memory 2352.71k
OS Memory 30908.00k
Timestamp 04/24/2022 02:13:39 PM
Step Count 377 Switch Count 3
Page Faults 0
Page Reclaims 367
Page Swaps 0
Voluntary Context Switches 8
Involuntary Context Switches 1
Block Input Operations 0
Block Output Operations 8
 
80
81 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 
manthan
Fluorite | Level 6

omg I figured out the problem. SGLT2 had no observations it was all missing sorry.. so stupid of me.. once I took this variable out it worked.. 

sbxkoenk
SAS Super FREQ

Hello,

 

Thanks for giving us that feedback.
If you now mark this topic as 'SOLVED', we are all done. 😉

 

Thanks,

Koen

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 935 views
  • 0 likes
  • 3 in conversation