Hi!
I need some help trouble shooting this syntax. Trying to change all my character strings for time varialbes into formated sas time variables. I'm getting error 'Illegal Regerence to the array _num'.
Here is my syntax
data med.time2006;
set med.time2006 (keep=TranAlert TranLaunch TranOnScene TranRecov TranDeliv GCSTime
VitalTime1 VitalTime2 VitalTime3 VitalTime4 VitalTime5 VitalTime6
MedGiveTime1 MedGiveTime2 MedGiveTime3 MedGiveTime4 MedGiveTime5 MedGiveTime6 MedGiveTime7
IV1Time IV2Time PainScaleTime1 PainScaleTime2 PainScaleTime3 PainScaleTime4 PainScaleTime5 PainScaleTime6
rename=(tranalert=tranalert_a TranLaunch=tranlaunch_a TranOnScene=tranonscene_a TranRecov=tranrecov_a
TranDeliv=trandeliv_a GCSTime=gcstime_a VitalTime1=vitaltime1_a VitalTime2=vitaltime2_a VitalTime3=vitaltime3_a VitalTime4=vitaltime4_a
VitalTime5=vitaltime5_a VitalTime6=vitaltime6_a MedGiveTime1=medgivetime1_a MedGiveTime2=medgivetime2_a MedGiveTime3=medgivetime3_a
MedGiveTime4=medgivetime4_a MedGiveTime5=medgivetime5_a MedGiveTime6=medgivetime6_a MedGiveTime7=medgivetime7_a
IV1Time=IVTime_a IV2Time=IVTime2_a PainScaleTime1=painscaletime1_a PainScaleTime2=painscaletime2_a PainScaleTime3=painscaletime3_a
PainScaleTime4=painscaletime4_a PainScaleTime5=painscaletime5_a PainScaleTime6=painscaletime6_a ));
array _char (*) $ TranAlert_a TranLaunch_a TranOnScen_a TranReco_a TranDeliv_a GCSTime_a
VitalTime1_a VitalTime2_a VitalTime3_a VitalTime4_a VitalTime5_a VitalTime6_a
MedGiveTime1_a MedGiveTime2_a MedGiveTime3_a MedGiveTime4_a MedGiveTime5_a MedGiveTime6_a MedGiveTime7_a
IV1Time_a IV2Time_a PainScaleTime1_a PainScaleTime2_a PainScaleTime3_a PainScaleTime4_a PainScaleTime5_a PainScaleTime6_a;
array _num (*) TranAlert TranLaunch TranOnScene TranRecov TranDeliv GCSTime
VitalTime1 VitalTime2 VitalTime3 VitalTime4 VitalTime5 VitalTime6
MedGiveTime1 MedGiveTime2 MedGiveTime3 MedGiveTime4 MedGiveTime5 MedGiveTime6 MedGiveTime7
IV1Time IV2Time PainScaleTime1 PainScaleTime2 PainScaleTime3 PainScaleTime4 PainScaleTime5 PainScaleTime6;
do i=1 to dim(_char);
_num=input(_char(i),best12.);
_num=hms(floor(_num/100),mod(_num,100),0);
format _num time12.;
end;
run;
Help is appreciated!
Try replacing all appearances of _num with _num(i), and in the format statement, use the actual variable names instead of the array name _num;
I'll let you do the counting. You need to have the exact same number of variables in _char and _num. Do you?
Try replacing all appearances of _num with _num(i), and in the format statement, use the actual variable names instead of the array name _num;
@PaigeMiller It worked! Thank you so much!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.