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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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;

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

I'll let you do the counting. You need to have the exact same number of variables in _char and _num. Do you?

--
Paige Miller
jenim514
Pyrite | Level 9
@PaigeMiller Yes, I double counted...27
PaigeMiller
Diamond | Level 26

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;

--
Paige Miller
jenim514
Pyrite | Level 9

@PaigeMiller It worked!  Thank you so much!

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 618 views
  • 0 likes
  • 2 in conversation