Date: Wed, 31 Mar 2004 13:24:50 -0500
Reply-To: Quentin McMullen <quentin_mcmullen@BROWN.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Quentin McMullen <quentin_mcmullen@BROWN.EDU>
Subject: Re: Creating macro variables from a dataset
Hi Renee,
I suggest you convert all your variables to be character, than transpose
e.g.:
data mparam;
length InputDS $12 gtitle1 $50;
InputDS='qcdata';
GTitle1='Acme Company';
Min= '0';
Max='40';
run;
proc transpose data=mparam out=a;
var _all_;
run;
data _null_;
set a;
call symput(_name_,trim(col1));
run;
%put &InputDS >itle1 &Min &Max;
Kind Regards,
--Quentin
On Wed, 31 Mar 2004 12:55:03 -0500, Renee Jaramillo
<rjaramillo@CONSTELLAGROUP.COM> wrote:
>Hi All,
>
>I want to be clever about creating some macro variables and I figure who
>better to ask then the clever folks at SAS-L! : )
>
>I have a SAS dataset with one observation and four variables and I need to
>convert each observation into a macro variable. Right now I am using DATA
>_NULL_ and CALL SYMPUT for each variable.
>
>*** DATASET WITH MACRO PARAMETERS ***;
>data mparam;
> length InputDS $12 gtitle1 $50;
> InputDS='qcdata';
> GTitle1='Acme Company';
> Min= 0;
> Max=40;
>run;
>
>data _null_;
> set mparam;
> call symput('InputDS',InputDS);
> call symput('GTitle1',GTitle1);
> call symput('Min',Min);
> call symput('Max',Max);
>run;
>
>I want to generalize this so that for a dataset with 10, 20, 50, . . .
>variables, I can convert each dataset variable into a macro variable
>without explicitly creating a CALL SYMPUT statement for each variable.
>
>Any suggestions how to go about this? I have a vague idea about using
PROC
>CONTENTS to get a list of every variable in the dataset, and then creating
>a macro that will use the contents list to work through the dataset with
>CALL SYMPUT.
>
>I'd like to hear if anybody has already worked on this problem.
>
>Thanks!
>Renee
|