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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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