Prev: Read/update google spreadsheets
Next: How do I reference files locally in Enterprise Guide when all I have is a remote server
From: bedcurt on 4 Jun 2010 07:05 The attached SAS is used to generate macro vars from a dataset, the first section of the SQL works however when I have tried to generate macro variables from the macro beta, they do not generate, can anyone help ? %macro betas; %do x=1 %to 62; select dumvin&x into : b_dumvin&x from dataxvin2_model; %end; %mend; proc sql noprint ; select Intercept into : Itrcpt from dataxvin2_model; select balms_l1 into : b_balms_l1 from dataxvin2_model; select balao_l1 into : b_balao_l1 from dataxvin2_model; select balhs_l1 into : b_balhs_l1 from dataxvin2_model; %betas; quit;
From: Alex_DPC on 4 Jun 2010 07:26 Hi bedcurt, Macro variables created with PROC SQL are created in the local symbol table. Try declaring the variables b_dumvin&x outside of your macro. Or declare them as global inside it. But I wouldn't recommend the latter. It's good practice to avoid global variables to avoid conflicts. Best, Alex On Jun 4, 1:05 pm, bedcurt <timandsa...(a)bedcurt.eclipse.co.uk> wrote: > The attached SAS is used to generate macro vars from a dataset, the > first section of the SQL works however when I have tried to generate > macro variables from the macro beta, they do not generate, can anyone > help ? > > %macro betas; > %do x=1 %to 62; > select dumvin&x into : b_dumvin&x > from dataxvin2_model; > %end; > %mend; > > proc sql noprint ; > > select Intercept into : Itrcpt > > from dataxvin2_model; > > select balms_l1 into : b_balms_l1 > > from dataxvin2_model; > > select balao_l1 into : b_balao_l1 > > from dataxvin2_model; > > select balhs_l1 into : b_balhs_l1 > > from dataxvin2_model; > > %betas; > > quit;
From: bedcurt on 4 Jun 2010 08:14 On Jun 4, 12:26 pm, Alex_DPC <alexander.k...(a)iea-dpc.de> wrote: > Hi bedcurt, > > Macro variables created with PROC SQL are created in the local symbol > table. Try declaring the variables b_dumvin&x outside of your macro. > Or declare them as global inside it. But I wouldn't recommend the > latter. It's good practice to avoid global variables to avoid > conflicts. > > Best, > Alex > > On Jun 4, 1:05 pm, bedcurt <timandsa...(a)bedcurt.eclipse.co.uk> wrote: > > > > > The attached SAS is used to generate macro vars from a dataset, the > > first section of the SQL works however when I have tried to generate > > macro variables from the macro beta, they do not generate, can anyone > > help ? > > > %macro betas; > > %do x=1 %to 62; > > select dumvin&x into : b_dumvin&x > > from dataxvin2_model; > > %end; > > %mend; > > > proc sql noprint ; > > > select Intercept into : Itrcpt > > > from dataxvin2_model; > > > select balms_l1 into : b_balms_l1 > > > from dataxvin2_model; > > > select balao_l1 into : b_balao_l1 > > > from dataxvin2_model; > > > select balhs_l1 into : b_balhs_l1 > > > from dataxvin2_model; > > > %betas; > > > quit;- Hide quoted text - > > - Show quoted text - I have declared the variabales using this: %macro dec; %do x=1 %to 62; dumvin&x %end; %mend; %global %dec; But they are still being generated locally
From: Alex_DPC on 4 Jun 2010 08:26 On Jun 4, 2:14 pm, bedcurt <timandsa...(a)bedcurt.eclipse.co.uk> wrote: > On Jun 4, 12:26 pm, Alex_DPC <alexander.k...(a)iea-dpc.de> wrote: > > > > > Hi bedcurt, > > > Macro variables created with PROC SQL are created in the local symbol > > table. Try declaring the variables b_dumvin&x outside of your macro. > > Or declare them as global inside it. But I wouldn't recommend the > > latter. It's good practice to avoid global variables to avoid > > conflicts. > > > Best, > > Alex > > > On Jun 4, 1:05 pm, bedcurt <timandsa...(a)bedcurt.eclipse.co.uk> wrote: > > > > The attached SAS is used to generate macro vars from a dataset, the > > > first section of the SQL works however when I have tried to generate > > > macro variables from the macro beta, they do not generate, can anyone > > > help ? > > > > %macro betas; > > > %do x=1 %to 62; > > > select dumvin&x into : b_dumvin&x > > > from dataxvin2_model; > > > %end; > > > %mend; > > > > proc sql noprint ; > > > > select Intercept into : Itrcpt > > > > from dataxvin2_model; > > > > select balms_l1 into : b_balms_l1 > > > > from dataxvin2_model; > > > > select balao_l1 into : b_balao_l1 > > > > from dataxvin2_model; > > > > select balhs_l1 into : b_balhs_l1 > > > > from dataxvin2_model; > > > > %betas; > > > > quit;- Hide quoted text - > > > - Show quoted text - > > I have declared the variabales using this: > > %macro dec; > %do x=1 %to 62; > dumvin&x > %end; > %mend; > > %global %dec; > > But they are still being generated locally Are you sure? I get them listed as global when I run this: %macro dec; %do x=1 %to 62; dumvin&x %end; %mend; %global %dec; %put _global_;
From: bedcurt on 4 Jun 2010 09:16
On Jun 4, 1:26 pm, Alex_DPC <alexander.k...(a)iea-dpc.de> wrote: > On Jun 4, 2:14 pm, bedcurt <timandsa...(a)bedcurt.eclipse.co.uk> wrote: > > > > > > > On Jun 4, 12:26 pm, Alex_DPC <alexander.k...(a)iea-dpc.de> wrote: > > > > Hi bedcurt, > > > > Macro variables created with PROC SQL are created in the local symbol > > > table. Try declaring the variables b_dumvin&x outside of your macro. > > > Or declare them as global inside it. But I wouldn't recommend the > > > latter. It's good practice to avoid global variables to avoid > > > conflicts. > > > > Best, > > > Alex > > > > On Jun 4, 1:05 pm, bedcurt <timandsa...(a)bedcurt.eclipse.co.uk> wrote: > > > > > The attached SAS is used to generate macro vars from a dataset, the > > > > first section of the SQL works however when I have tried to generate > > > > macro variables from the macro beta, they do not generate, can anyone > > > > help ? > > > > > %macro betas; > > > > %do x=1 %to 62; > > > > select dumvin&x into : b_dumvin&x > > > > from dataxvin2_model; > > > > %end; > > > > %mend; > > > > > proc sql noprint ; > > > > > select Intercept into : Itrcpt > > > > > from dataxvin2_model; > > > > > select balms_l1 into : b_balms_l1 > > > > > from dataxvin2_model; > > > > > select balao_l1 into : b_balao_l1 > > > > > from dataxvin2_model; > > > > > select balhs_l1 into : b_balhs_l1 > > > > > from dataxvin2_model; > > > > > %betas; > > > > > quit;- Hide quoted text - > > > > - Show quoted text - > > > I have declared the variabales using this: > > > %macro dec; > > %do x=1 %to 62; > > dumvin&x > > %end; > > %mend; > > > %global %dec; > > > But they are still being generated locally > > Are you sure? I get them listed as global when I run this: > > %macro dec; > %do x=1 %to 62; > dumvin&x > %end; > %mend; > > %global %dec; > > %put _global_;- Hide quoted text - > > - Show quoted text - Please ignore got it to work, thanks |