DATA Step, Macro, Functions and more

Concomitant therapies at different levels.

Reply
Contributor L_L
Contributor
Posts: 56

Concomitant therapies at different levels.

Dear all

In attachment you will find an extract of the input datasets.

I have to summarize data about therapies as in the table below:

Total patients
Level1Level2N (%)
CardiacName1   xx(xx%)
Name2xx(xx%)
...xx(xx%)
...
Total patientsxx(100%)

The percentages are to be calculated on the basis of total patient and a patient could have more than one therapy.

Could you suggest a simple method of programming?

Thank you in advance

Regards

Occasional Contributor
Posts: 7

Re: Concomitant therapies at different levels.

could be something like:

 

proc import datafile='sasc.xls' out=sasc_in dbms=excel replace;
   sheet="foglio1$"; getnames=yes; mixed=yes; scantext=yes;
quit;

proc sql noprint;
   * Denominator: Subject Count in Total;
   select distinct n(distinct pt_id) into :pt_n from sasc_in
   where pt_id is not null;
quit;

%let pt_n=%left(%trim(&pt_n));

proc transpose out=sasc_tr( where=(upcase(_name_) not in('_' 'PT_ID') and col1^=''));
   var _all_; by pt_id;
quit;

data sasc_name;
   set;
   array name[*] $32. therapy level;
   drop i _:;
   do i=1 to dim(name);
      name[i] = scan(_name_, i, '_');
   end;
run;

proc sort; by pt_id therapy level;
quit;

* Level-1 and Level-2 per Patient per Therapy;
data sasc;
   merge sasc_name( in=_l1 where=(upcase(level)='LEVEL1') rename=(col1=level1))
         sasc_name( in=_l2 where=(upcase(level)='LEVEL2') rename=(col1=level2));
   by pt_id therapy;
   drop level;
   * Each Level Combination;
   level_n =1; output;
   * Total;
   level_n =2;
   level1 = "Total";
   level2 = "";
   therapy = ""; output;
run;

proc sort noduprecs; by level_n level1 level2 pt_id therapy;
quit;

* Subject Count per Combination of Levels;
proc freq noprint;
   by level_n level1;
   table level2/out=sasc_freq( drop=percent) sparse;
quit;

* Percentages;
data sasc_pct;
   set;
   n_pct = put(count, 2.)||' ('||put(100*count/&pt_n, 5.1)||'%)';
run;

 

just not sure how "simple" you consider it.

Ask a Question
Discussion stats
  • 1 reply
  • 238 views
  • 0 likes
  • 2 in conversation