BookmarkSubscribeRSS Feed
BAGaucho
Obsidian | Level 7

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.

5 REPLIES 5
mkeintz
PROC Star

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

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
BAGaucho
Obsidian | Level 7
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;
Reeza
Super User
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?
BAGaucho
Obsidian | Level 7

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.

SuzanneDorinski
Lapis Lazuli | Level 10

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;

Output from PROC SQL showing differences in treat variableOutput from PROC SQL showing differences in treat variable

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
  • 5 replies
  • 4807 views
  • 0 likes
  • 4 in conversation