I don't think the FORMAT statement accepts an array reference. Remove the FORMAT statement from the loop, and just code:
format Assign_date1-Assign_date50 date9.;
FORMAT statements want the name(s) of the VARIABLES. I cannot take an indirect reference to a variable since it it is not executable. It just defines what format to attach to the vairable.
data test;
set dataset ;
array assign_date [50] ;
array new_date [50] ;
format new_date1-new_date50 date9.;
do I =1 to 50;
new_date[i] = input(assign_date[i] , yymmdd10.);
end;
drop I;
run;
Format statement does not recognize array references.
However you can use a single format statement:
format new_date: date9.;
anywhere in the data step.
The colon is a list indicator and says "use all the variable names that start with New_date".
You can simplify your code a little bit by using:
Array new_date(50);
That will create variables named New_date1 through New_date50 and you use New_date[i] .
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.