BookmarkSubscribeRSS Feed
Aidaan_10
Calcite | Level 5

Hi All,

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

proc tabulate data= data2a out=baseline (drop=_:);
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

3 REPLIES 3
ballardw
Super User

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.

 

 

Aidaan_10
Calcite | Level 5

 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...

Aidaan_10
Calcite | Level 5

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' .

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1841 views
  • 0 likes
  • 2 in conversation