DATA Step, Macro, Functions and more

Calculation of Baseline values

Reply
Occasional Contributor
Posts: 14

Calculation of Baseline values

Hi All,

               I have to calculate baseline for two different visits for which I used this step 

proc tabulate data= data2a out=baseline (drop=_Smiley Happy;
where visit in('Period1' 'Period2');
class tests visit;
var aval;
table tests*visit*aval* ( mean);
run;

My dataset baseline would be something like this:

Tests    Visit                  Aval_Mean 

ABC     Period1            12345

ABC     Period2            67890

DEF    Period1             56789

DEF    Period2             93489

 

            And I have the  AVAL_MEAN value for two different visits , so now when I merge this baseline data with post baseline visits by tests the AVAL_MEAN from period1 Values are getting overwritten by period2  values for postbaseline visits something like this:

 

Tests    Visit                  Aval_Mean 

ABC     Period1                      12345

ABC     Period1_day3            67890

ABC     Period1_day4          67890

ABC     Period2                     67890

ABC     Period2_day3           67890

ABC     Period2_day4          67890

 

 

but I dont need this and I need something like this:

Tests    Visit                  Aval_Mean 

ABC     Period1                      12345

ABC     Period1_day3            12345

ABC     Period1_day4          12345

ABC     Period2                    67890

ABC     Period2_day3           67890

ABC     Period2_day4          67890

                        Can someone please suggest me a workaround for this...Any help will be greatly appreciated...Thanks

Super User
Posts: 13,008

Re: Calculation of Baseline values

Posted in reply to Aidaan_10

Show how you are combining the data sets.

It sounds like you are using merge and have a same named variable in both sets. The order of the sets in merge determines which value is kept with same named variables. Perhaps you need to rename a variable. But without a better example of both data sets it isn't clear.

 

 

Occasional Contributor
Posts: 14

Re: Calculation of Baseline values

 I am merging them by tests..

               data data4;
merge baseline data3;
by tests ;

run;

         If I use visit in the by statement then I am getting the aval_mean value just for the the period1 and period2 visits and missing for postbaseline visits...

Occasional Contributor
Posts: 14

Re: Calculation of Baseline values

Posted in reply to Aidaan_10

And also I would like to add something here...which I missed the visits for baseline are 'Period1_day-1' 'Period2_day-2' and not just Period1' 'Period2' .

Ask a Question
Discussion stats
  • 3 replies
  • 93 views
  • 0 likes
  • 2 in conversation