I am attempting to calculate "11065865311" across a table of hourly data (hours 1 thru 24). The array that I tried to setup below does not work, actually errors out. Is this the correct path?
data work.delete_Main(drop=i);
set work.delete_merging;
array hours {24} 4 H1-H24;
do i=(hour1) to 1 by -1;
hours[i]=100;
end;
do i=(hour1);
hours[i]=hours/11065865311;
end;
output;
run;
I repeat, your problem is in the NUMERATOR of hours/11065865311. You need something like hours{I}/11065865311
The numerator in the expression
hours/11065865311
should be generating a "error: illegal reference to the array hours" message.
You need to specify an index (i.e. hours{i}, hours{3}, etc.) in the numerator.
If you get an error, posting the log is essential.
Agreed, thank you. the log is what @mkeintz mentioned.
ERROR: Illegal reference to the array hours.
The SAS System 08:48 Monday, October 2, 2017
1 %_eg_hidenotesandsource;
5 %_eg_hidenotesandsource;
46
47
48
49 data work.delete_Main(drop=i);
50 /*retain State City Date Dawn Dusk Hour1 Minute1 Hour2 Minute2 ;*/
51 set work.delete_merging;
52
53 array hours {24} 4 H1-H24;
54
55 do i=(hour1) to 1 by -1;
56 hours[i]=100;
57 end;
58
59
60 do i=(hour1);
61 hours[i]=hours/11065865311;
ERROR: Illegal reference to the array hours.
62 end;
63
64 output;
65 run;
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
61:27
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.DELETE_MAIN may be incomplete. When this step was stopped there were 0 observations and 33 variables.
WARNING: Data set WORK.DELETE_MAIN was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
Yes, you can't use the whole array in an assignment, you have to use individual members.
So am I changing the array script to:
array hours {3} H1 - H24;
do i=1 to 3;
hours{i}=hours/11065865311;
I am not understanding how I the array should be modified.
hours without an index (as you used it on the right side of the assignment) is invalid.
I repeat, your problem is in the NUMERATOR of hours/11065865311. You need something like hours{I}/11065865311
Thank you @mkeintz and @Kurt_Bremser.
After your initial reply, I did change the numerator to show the index.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.