From: toby dunn on 13 Sep 2006 12:53 SAS-Learner, If you must do this drop the macro and SWL and just use a Data _Null_ step with call execute. Data _Null_ ; Set Derive.AE ; Call Execute( 'Data ' || Compress( Region ) || ' ;' ) ; Call Execute( 'Set AE( Where = ( Region = '" || Strip( Region ) || "' ) ;" ) ; Call Execute( 'Run ;' ) ; Run ; Toby Dunn When everything is coming at you all at once, your in the wrong lane. A truly happy person is someone who can smile and enjoy the scenery on a detour. From: SAS_learner <proccontents(a)GMAIL.COM> Reply-To: SAS_learner <proccontents(a)GMAIL.COM> To: SAS-L(a)LISTSERV.UGA.EDU Subject: How to get Individual Region value from the macro list ??????? Date: Wed, 13 Sep 2006 11:45:09 -0500 hello guys , I am getting a list of regions like this 4957 proc sql noprint ; 4958 select distinct(region) into : reg separated by ',' 4959 from derive.ae; 4960 %put ® Europe,Latin America,US/Canada 4961 quit; Now I need to value of individual region in a varaible so that I can use for my subsetting purpose . For this I am doing some thing like this %reg = Europe; data V_AE1 ; set AE(where=(region = "®")); run; %reg = Latin America; data V_AE1 ; set AE(where=(region = "®")); run; I can't do this because regions may increase with the data change so I want to caputure the individual regions and pass that value to subset condition ? Any Idea how to do this ??
From: Gerhard Hellriegel on 13 Sep 2006 13:02 you could write your regions in a numbered macro variable (kind of a simulated macro-array): data _null_; set derive.ae; call symput("no",_n_); call symput("n"!!compress(put(_n_,8.)),region); run; then you can use them in a macro loop which generates the data-steps with individual where-clauses: .... %do i=1 %to &no; data ae_&i; set AE(where=(region = "&&n&i")); run; %end; That generates a data-step for each available region and **don't** overwrite it, but numbers the output dataset AE_1, AE_2, ... For sure you must put that in a macro, otherwise a %do loop is not possible. Regards, Gerhard On Wed, 13 Sep 2006 11:45:09 -0500, SAS_learner <proccontents(a)GMAIL.COM> wrote: >hello guys , > >I am getting a list of regions like this > >4957 proc sql noprint ; >4958 select distinct(region) into : reg separated by ',' >4959 from derive.ae; >4960 %put ® >Europe,Latin America,US/Canada >4961 quit; >Now I need to value of individual region in a varaible so that I can use for >my subsetting purpose . >For this I am doing some thing like this > >%reg = Europe; > >data V_AE1 ; > set AE(where=(region = "®")); > >run; > >%reg = Latin America; > >data V_AE1 ; > set AE(where=(region = "®")); > >run; >I can't do this because regions may increase with the data change so I want >to caputure the >individual regions and pass that value to subset condition ? Any Idea how to >do this ??
From: SAS_learner on 13 Sep 2006 14:35 sorry guys I think this lack of planning a head what I am trying to do is generating a AEV table with different regions, I getting what I want by doing something like this *For Europe; %cou(reg = Europe, ds= eu ); *For Latin America ; %let ds = la ; %cou(reg = Latin America, ds= la ); *For Us an canada ; %let ds = uc ; %cou(reg = US/Canada, ds= uc ); these are the distinct values I getting from AE table, is there a way to distinct values of region to my %cou ( reg = ® , ds = ® (this is for my debuging purpose only ) )
From: Robert Bardos on 14 Sep 2006 03:55 Dear SAS_learner, PROC SQL can do more than "select distinct x into :y separated by ' '". It can also do "select distinct x into :y1 - :y9999". As it sets the automatic variable &sqlobs at the same time you will know how many &y (with a numeric suffix) have been generated. It will not generate 9999 variables. Only as much as there are distinct values. So basically it boils down to something like (untested): %macro reg_loop(num_regs=); %do i=1 %to &num_regs; proc print data=derive.ae (where=(region="&®&i")); run; %end; %mend reg_loop; proc sql noprint; select distinct reg into :reg1 - :reg9999 from derive.ae; quit; %put &sqlobs distinct values found.; %reg_loop ( num_regs = &sqlobs ); HTH Robert Bardos Ansys AG, Z?rich, Switzerland -----Urspr?ngliche Nachricht----- Von: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU]Im Auftrag von SAS_learner Gesendet: Mittwoch, 13. September 2006 20:35 An: SAS-L(a)LISTSERV.UGA.EDU Betreff: Re: How to get Individual Region value from the macro list ??????? sorry guys I think this lack of planning a head what I am trying to do is generating a AEV table with different regions, I getting what I want by doing something like this *For Europe; %cou(reg = Europe, ds= eu ); *For Latin America ; %let ds = la ; %cou(reg = Latin America, ds= la ); *For Us an canada ; %let ds = uc ; %cou(reg = US/Canada, ds= uc ); these are the distinct values I getting from AE table, is there a way to distinct values of region to my %cou ( reg = ® , ds = ® (this is for my debuging purpose only ) )
|
Pages: 1 Prev: proc sql & left join & where statement Next: Converting Cobol PIC to SAS informats |