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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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