This does not really make any sense.
Please show some example input and what output you want for that input.
In that case show an example of that situation.
Sounds like you say three sets of month,day, year variables. Something like:
ID M1 D1 Y1 M2 D2 Y2 M3 D3 Y3
1 1 1 1980 2 2 1990 3 3 2000
And you want to generate three date variables.
So you could create a separate array for each of the types of variables and then loop over an index into the array to apply the same logic to each of the arrays.
data want;
set have;
array m m1-m3;
array d d1-d3;
array y y1-y3 ;
array date date1-date3;
do index=1 to dim(m);
date[index] = mdy(m[index],d[index],y[index]);
end;
format date1-date3 yymmdd10.;
drop index;
run;
Result:
Obs ID M1 D1 Y1 M2 D2 Y2 M3 D3 Y3 date1 date2 date3 1 1 1 1 1980 2 2 1990 3 3 2000 1980-01-01 1990-02-02 2000-03-03
If the values of the month variable are things like -1 and -13 in your example then the resulting DATE variable will be missing since such values cannot be used to generate a valid date.
If your real situation is different than my example then show a similar level of detail for your real problem.
hey,
wht if the year is not a variable in the data set and its just mentioned in the question that all of the month and date variable have year of 1990, then how to appraoch
If you have a NEW question then start a new topic.
You can easily hard code the year, just use the actual value instead of a variable name.
date = mdy(month,day,1980);
hi i am solving a similar question did u get an proper answer
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.