Convert data-set variable to macro variable

  • Follow


Say, does anyone have a macro handy that converts a column from a data
set into a macro variable containing a list of the same values. For
example, convert x_data into x_var below.

I imagine this isn't too hard, but involves one of the many SAS tricks
that I don't know. Thanks for sharing your magic.

Paul

data x_data;
input x;
datalines;
1
2
3
;
run;

%let x_var = 1 2 3;

0
Reply paulvonhippel (114) 7/12/2006 1:50:20 PM

Paul wrote:
> Say, does anyone have a macro handy that converts a column from a data
> set into a macro variable containing a list of the same values. For
> example, convert x_data into x_var below.
>
> I imagine this isn't too hard, but involves one of the many SAS tricks
> that I don't know. Thanks for sharing your magic.
>
> Paul
>
> data x_data;
> input x;
> datalines;
> 1
> 2
> 3
> ;
> run;
> 
> %let x_var = 1 2 3;

0
Reply dramage1 (15) 7/12/2006 2:08:40 PM


Try this:

proc sql;
select x into : var1 separated by " "
		from x_data;
quit;

%put &var1;


> Paul wrote:
> > Say, does anyone have a macro handy that converts a column from a data
> > set into a macro variable containing a list of the same values. For
> > example, convert x_data into x_var below.
> >
> > I imagine this isn't too hard, but involves one of the many SAS tricks
> > that I don't know. Thanks for sharing your magic.
> >
> > Paul
> >
> > data x_data;
> > input x;
> > datalines;
> > 1
> > 2
> > 3
> > ;
> > run;
> > 
> > %let x_var = 1 2 3;

0
Reply dramage1 (15) 7/12/2006 2:10:29 PM

2 Replies
23 Views

(page loaded in 0.1 seconds)

Similiar Articles:













7/14/2012 6:26:53 PM


Reply: