From: Henry on 6 Mar 2010 18:19 Hi All, I wrote a simple macro code to generate 6 new variables: My original data set looks like: t1 t2 t3 p1 p2 p3 Then I would like my new dat looks like: t1 t2 t3 p1 p2 p3 tv1 tv2 tv3 pv1 pv2 pv3 But I am not sure what I did wrong below. Can anyone give me some advices? Thank you so much!!! %macro val; %do j = 1 %to 3 ; data forward3; set forward2; if p&j<0.1 then pv&j='* '; else if p&j<0.05 then pv&j='** '; else if p&j<0.01 then pv&j='***'; tv&j=put(t&j,7.2); %end; %mend; %val;
From: Arthur Tabachneck on 6 Mar 2010 19:07 Henry, I can only presume that you are trying to do something like: data forward2; input t1-t3 p1-p3; cards; 1 1 1 .06 .049 .01 2 2 2 .01 .048 .009 ; %macro val; data forward3; set forward2; %do j = 1 %to 3 ; if p&j<0.01 then pv&j='***'; else if p&j<0.05 then pv&j='** '; else if p&j<0.1 then pv&j='* '; tv&j=put(t&j,7.2); %end; run; %mend; %val If I'm correct, look at the differences between your and my suggested code. Stating from the bottom: (1) don't add a semi-colon after a macro call; (2) ensure that your logic is listed logically; and (3) ensure that your %do loop is placed correctly to accomplish what you want to do. HTH, Art ------------ On Mar 6, 6:19 pm, Henry <chchanghe...(a)gmail.com> wrote: > Hi All, > > I wrote a simple macro code to generate 6 new variables: > My original data set looks like: > > t1 t2 t3 p1 p2 p3 > > Then I would like my new dat looks like: > t1 t2 t3 p1 p2 p3 tv1 tv2 tv3 pv1 pv2 pv3 > > But I am not sure what I did wrong below. Can anyone give me some > advices? Thank you so much!!! > > %macro val; > %do j = 1 %to 3 ; > data forward3; > set forward2; > if p&j<0.1 then pv&j='* '; > else if p&j<0.05 then pv&j='** '; > else if p&j<0.01 then pv&j='***'; > tv&j=put(t&j,7.2); > %end; > %mend; > %val;
From: Henry on 6 Mar 2010 23:37 Hi Art, Thank you so much for correcting my errors!! Really appreciated!! Henry On Mar 6, 5:07 pm, art...(a)NETSCAPE.NET (Arthur Tabachneck) wrote: > Henry, > > I can only presume that you are trying to do something like: > > data forward2; > input t1-t3 p1-p3; > cards; > 1 1 1 .06 .049 .01 > 2 2 2 .01 .048 .009 > ; > > %macro val; > data forward3; > set forward2; > %do j = 1 %to 3 ; > if p&j<0.01 then pv&j='***'; > else if p&j<0.05 then pv&j='** '; > else if p&j<0.1 then pv&j='* '; > tv&j=put(t&j,7.2); > %end; > run; > %mend; > %val > > If I'm correct, look at the differences between your and my suggested > code. Stating from the bottom: (1) don't add a semi-colon after a > macro call; (2) ensure that your logic is listed logically; and (3) > ensure that your %do loop is placed correctly to accomplish what you > want to do. > > HTH, > Art > ------------ > On Mar 6, 6:19 pm, Henry <chchanghe...(a)gmail.com> wrote: > > > Hi All, > > > I wrote a simple macro code to generate 6 new variables: > > My original data set looks like: > > > t1 t2 t3 p1 p2 p3 > > > Then I would like my new dat looks like: > > t1 t2 t3 p1 p2 p3 tv1 tv2 tv3 pv1 pv2 pv3 > > > But I am not sure what I did wrong below. Can anyone give me some > > advices? Thank you so much!!! > > > %macro val; > > %do j = 1 %to 3 ; > > data forward3; > > set forward2; > > if p&j<0.1 then pv&j='* '; > > else if p&j<0.05 then pv&j='** '; > > else if p&j<0.01 then pv&j='***'; > > tv&j=put(t&j,7.2); > > %end; > > %mend; > > %val;
|
Pages: 1 Prev: S.E. & C.D. in Split Plot design with SAS Next: new joinee |