BookmarkSubscribeRSS Feed
juju_p
Obsidian | Level 7

Hello,

 

I would like to ask about a specific problem, I am new to SAS , working on an existing code and I am facing some issues to update it.

 

I have the following data printed on screen and I would like that for each Timepoint, whenever the combination of 'Lesion Type', Total Sum', 'Lesion evaluation' and  'Overall evaluation' is the same on multiple rows, I would like to show it only once.

 

So, for Subject 'A' the lines with the arrow should be listed one after each other. the values in purple should be printed and the values in yellow should not be printed because they are repeated.

 

Below are the existing code to create the dataset and also to create the report

 

Create Dataset

 

data lesrt3;
set lesrt2;
by subjid RECISTNR timept ord;
if first.ord then do;
lestype1=lestype;
eval1=eval;
TLSLDd=put(TLSLD, 9.0);
end;
else do;
lestype1='';
eval='';
TLSLDd='';
end;
if lestype='Non-Target Lesion' then tlsldd='';
if TIMEP = 99 then TIMEPT_ = compbl('Other follow-up: Week '|| compress(put(TIMEPTW,3.)));
else timept_=timept;

CTDat = CATS(DDCT1,'$',DDCT2,'$',DDCT3);
MRIDat = CATS (DDMRI1,'$',DDMRI2,'$',DDMRI3);
XRDat = CATS (DDXR1,'$',DDXR2,'$',DDXR3);
PETDAT = CATS (DDPET1,'$',DDPET2,'$',DDPET3);
OTHDAT = CATS (DDOTH1,'$',DDOTH2,'$',DDOTH3);
if LESTEC =1 then RTADAT = CTDat;
else if LESTEC =2 then RTADAT = MRIDat;
else if LESTEC =3 then RTADAT = XRDat;
else if LESTEC =4 then RTADAT = PETDAT;
else if LESTEC =5 then RTADAT = OTHDAT;

if lestype ='Non-Target Lesion' then Leseval=evantlt;
if lestype ='Target Lesion' then Leseval=evatlt;
leseval_all= overevt;
run;

 

 

 

 

Print report

 

proc report data=lesrt3 nowd split='$' headskip headline /*spacing=1*/ missing;
column SUBJID TLESOB NTLESOB NLESOB LESTYPE RECISTNR TIMEPT_ LESORGT LESTECT LESSP TLSLD RTADAT ("Response Assessment$___" LESEVAL OVEREVT ) ;

define SUBJID / order 'Subject ID' width=12 left flow;
define TLESOB / group 'Target$Lesion$Observed' width=6 left format=fyn.;
define NTLESOB / group 'Non-$Target$Lesion$Observed' width=8 left format=fyn.;
define NLESOB / group 'New-$Lesions$Observed' width=8 left format=fyn.;
define LESTYPE / 'Lesions$Type' width=8 left flow;


define RECISTNR / order 'Nr' width=2 left;
define TIMEPT_ / group 'Time Point' width=10 left flow ;
define LESORGT / group 'Organ/Site' width=10 left flow;
define LESTECT / group 'Technique' width=9 left;
define LESSP / group 'Specification' width=13 left flow;
define TLSLD / group 'Total$Sum$TL' width=5 left;


define RTADAT / group 'Date$Of$Examination' width=10 left;

define LESEVAL / group 'Lesion$Evaluation' width=10 left flow ;
define OVEREVT / group 'Overall$Evaluation' width=10 left flow ;


break after subjid / skip;
run;

1 REPLY 1
JOL
SAS Employee JOL
SAS Employee

Try applying PROC SORT before doing your PROC REPORT.  PROC SORT is great for eliminating duplicate rows.  Here is generalized code based of the report you provided, fill in actual table and column names.  Be careful and name a new output table with OUT= so your original table is not over written.

 

proc sort data=source_table out=new_table nodupkey dupout=table_with_duplicates;
by lesiontype timepoint totalsum dateofexam lesioneval overalleval;
run;

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 1333 views
  • 0 likes
  • 2 in conversation