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] .
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.