ApeWithPants
ApeWithPants

Reputation: 104

Values in a column as a Macro Variable

I'm new to macros and need a little help.

My program produces a small table with unique rows. I'd like to be able to use the concatenated values of a column in this table in a macro variable.

so if the column if my table consists of values "Region1, Region2,...,RegionN", My macro variable reads "Region1 Region2 ... RegionN".

I've searched around a bit and can't find a good way to do this. If you know of anything I can reference that would walk me through this, I'd be much obliged.

Upvotes: 1

Views: 169

Answers (1)

Alex A.
Alex A.

Reputation: 5586

Try this...

proc sql noprint;
    select distinct region
    into: regionlist
    separated by " "
    from yourdataset
    order by region;
quit;

This creates a list of distinct values of your region variable ordered by region and separated by a space. See the SAS documentation on the INTO clause in PROC SQL for further reference.

Upvotes: 2

Related Questions