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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.