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] .
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.