Dear All,
Need help in generating repeated sequence. I have 3 inputs in macro variable
Min Value = 1 (Starting number of the sequence)
Max Value = 3 (Ending number of the sequence)
No of iterations = 2 (No of times the sequence to be repeated)
With the above input I would like to see a dataset with the below result.
1
2
3
1
2
3
@shankvi8 wrote:
Dear All,
Need help in generating repeated sequence. I have 3 inputs in macro variable
Min Value = 1 (Starting number of the sequence)
Max Value = 3 (Ending number of the sequence)
No of iterations = 2 (No of times the sequence to be repeated)
With the above input I would like to see a dataset with the below result.
1
2
3
1
2
3
You could at least provide the names of your macro variables, the name of the data set and variable in the dataset.
One way:
%let min= 1;
%let max= 3;
%let iter= 2;
data want;
do i= 1 to &iter;
do x=&min to &max;
output;
end;
end;
drop i;
run;
Caution: this makes to checks that max is greater than min.
@shankvi8 wrote:
Dear All,
Need help in generating repeated sequence. I have 3 inputs in macro variable
Min Value = 1 (Starting number of the sequence)
Max Value = 3 (Ending number of the sequence)
No of iterations = 2 (No of times the sequence to be repeated)
With the above input I would like to see a dataset with the below result.
1
2
3
1
2
3
You could at least provide the names of your macro variables, the name of the data set and variable in the dataset.
One way:
%let min= 1;
%let max= 3;
%let iter= 2;
data want;
do i= 1 to &iter;
do x=&min to &max;
output;
end;
end;
drop i;
run;
Caution: this makes to checks that max is greater than min.
data want;
do j=1 to &no_of_iterations;
do i=&minvalue to &maxvalue;
output;
end;
drop j;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.