DATA Step, Macro, Functions and more

Proc compare - control the length of ID and comparing variable length

Reply
New Contributor
Posts: 3

Proc compare - control the length of ID and comparing variable length

I have been using Proc Compare for a long time and I kind of ignoring this issue...

 

For clinical trials, USUBJID can be long as 20+ but I have to use USUBJID as ID variable when I use Proc Compare.

I am using linesize as 155 so there are plenty of blank space in my output. However, Proc Compare uses only limited length for ID value, Base value, and Compare value like 20. Is there any option or simple way to extend the length?

 

Yes, I know I can use OUT= option but it is much easier to use side-by-side comparison for so many variables for clinical trials data. I know, I know, I can transpose the OUT data, but I am a lazy guy to list all the variables. For validation purpose, I have to check all variables in both data and it can be 100+ variables. I also tried format the ID variable but no effect.

 

For ID statement, I can split the variable into 2 and use both to ID statement and work, but that will not be the ultimate solution.

 

If there is easy solution for this, please let me know. Or is there any future SAS Institute plan to enhance this issue? I have been using SAS for more than 30 years but it's hard to believe if SAS Institute hasn't come up with any simple solution.

Trusted Advisor
Posts: 1,297

Re: Proc compare - control the length of ID and comparing variable length

Please provide a small dummy data example, incorporated into a DATA step with INPUT statement, and a PROC COMPARE that demonstrates the problem.

New Contributor
Posts: 3

Re: Proc compare - control the length of ID and comparing variable length

OK, the typical data can be like this...

data base;
input @1 usubjid $22. @25 treat $30.;
card;
ABC-DEF-0110-1234-4567 Special cancer treatment 1
ABC-DEF-0110-4321-4567 Special cancer treatment 2
ABC-DEF-0112-1234-4567 Special cancer treatment 3
;
run;
data compare;
input @1 usubjid $22. @25 treat $30.;
card;
ABC-DEF-0110-1234-4567 Special cancer treatment 4
ABC-DEF-0110-4321-4567 Special cancer treatment 1
ABC-DEF-0112-1234-4567 Special cancer treatment 2
;
run;
proc compare base=base compare=compare;
id usubjid;
run;
Super User
Posts: 22,875

Re: Proc compare - control the length of ID and comparing variable length

It's not super easy, i.e. not an option you can set, but you can likely modify the ODS template to correct this issue.

PS. I assume your issue is that TREAT variable doesn't show the full value in the reports to see what the difference?
New Contributor
Posts: 3

Re: Proc compare - control the length of ID and comparing variable length

Thanks, but ODS output is not much different than using OUT= option.

 

Yeah, the main issue is that it's hard for me to see what is actually different from the reports since Proc Compare print out 20 characters.  I have to check source data to confirm or using OUT= option to see each chopped variables.

Too much work for me. I wish I can use format or length to control the reports just like Proc Print.

Frequent Contributor
Posts: 110

Re: Proc compare - control the length of ID and comparing variable length

I regularly deal with ID variables that are 21 characters long.  I don't use PROC COMPARE, for the reasons you have mentioned.

 

Instead, I write a macro and use SASHELP.VCOLUMN to get the list of variables to compare.  

 

proc sql;
  select b.usubjid,
         b.treat as base_treat,
         c.treat as compare_treat
    from base as b,
         compare c
      where b.usubjid=c.usubjid and
            base_treat ne compare_treat;
quit;

PROC SQL listing to show differences between data sets.jpgOutput from PROC SQL showing differences in treat variable

Ask a Question
Discussion stats
  • 5 replies
  • 292 views
  • 0 likes
  • 4 in conversation