J_Heads
J_Heads

Reputation: 489

Create a basic data set by specifying a range of values

I am trying to create a single variable for my the purpose of my macro function. What I want to do is simple. I want to create a dataframe with a single variable with a range of character values. For example:

forecast
fore1
fore2
fore3
fore4

I am aware of the some of the ways this can be done with the input and datalines statements, however, the issue I am having is that I want to use fore1-fore4 to generate the data in this dataframe so that it will generalize to my macro function.

Upvotes: 1

Views: 115

Answers (1)

Reeza
Reeza

Reputation: 21264

Assuming you literally want that data set, it could be as simple as this.

data want;
    do i=1 to 4;
        forecast = catt('fore', i);
        output;
    end;
    keep forecast;
 run;

Upvotes: 2

Related Questions