Upfront... just want to say thanks for the help...
I have the following code snipet for assigning values from a dataset to an array... I get an error message about converting numeric values to char values. I have not been able to find a solution to this. Would greatly appreciate any help...
---------------------------------------------------------------------------
%macro DefineInputArray;
ARRAY BYLINE(48) $16. BYLINE1 - BYLINE50;
%mend;
data sims;
set data_inputs;
%DefineInputArray;
format iter BEST.;
do i=1 to 50;
%let iter = 1000+(i-1)*1000;
BYLINE(i) = iVALUE&iter .;
end;
run;
---------------------------------------------------------------------------
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
---------------------------------------------------------------------------
Try using %eval() with the %let statement:
%let iter = %eval(1000+(i-1)*1000);
You will have a timing issue when using a macro %let statement in a data step. The %let statement will get executed before the data step so it won't be part of the data step iteration and you also can't pass a SAS data step variable to the %let statement. There your "i" will simply be interpreted as the character 'i'.
Not sure why you need a macro at all but as this is a code snippet reality might look different and there are good reasons for a macro. Below should make your code snippet work:
%macro DefineInputArray;
ARRAY BYLINE(50) $16. BYLINE1 - BYLINE50;
array iVal (50)
%do i=1 %to 50;
%let iter = %eval(1000+(&i-1)*1000);
iVALUE&iter
%end;
%str(;)
%mend;
data sims;
set data_inputs;
%DefineInputArray;
do i=1 to dim(BYLINE);
BYLINE = iVALUE;
end;
run;
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.