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