BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

I need to populates total number of subjects to all OBS in data1 to calculate percentages.

With my code the values from data2 only polulating to first OBS in data1. Please help. Thanks

 

code;

data3;

merge data1 data2;

run;

 

data1

 

Text                                                     100mg                      200mg            

Teae due to drug                                     10                            15

Teae due to procedure                            5                                8

mild teae                                                  3                                9

moderate teae                                         4                                6

 

data2 (Total number of subjects)

 

100mg                               200mg

50                                          65

 

output need;

 

Text                                                     100mg                      200mg     100mgTNS       200mgTNS

Teae due to drug                                     10                            15                 50                   65

Teae due to procedure                            5                                8                  50                  65

mild teae                                                  3                                9                 50                   65

moderate teae                                         4                                6                  50                  65

 

output getting;

ext                                                     100mg                      200mg     100mgTNS       200mg

Teae due to drug                                     10                            15                 50                   65

Teae due to procedure                            5                                8                

mild teae                                                  3                                9                

moderate teae                                         4                                6                  

2 REPLIES 2
art297
Opal | Level 21

This probably isn't the most efficient method, but it will work:

 

data data3 (drop=n);
  set data1;
  n=1;
  set data2 (rename=(_100mg=_100mgTNS _200mg=_200mgTNS)) point=n;
run;

HTH,

Art, CEO, AnalystFinder.com

 

 

Astounding
PROC Star

A commonplace method:

 

data data3;
  set data1;
  if _n_=1 then 
  set data2 (rename=(_100mg=_100mgTNS _200mg=_200mgTNS));
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 852 views
  • 2 likes
  • 3 in conversation