0

Is there a way to replicate the behaviour below using PROC SUMMARY without having to create the dummy variable UniqueKey?

DATA table1;
input record_desc $ record_id $ response;
informat record_desc $4. record_id $1. response best32.;
format record_desc $4. record_id $1. response best32.;
DATALINES;
  A001 1 300
  A001 1 150
  A002 1 200
  A003 1 150
  A003 1 99
  A003 2 250
  A003 2 450
  A003 2 250
  A004 1 900
  A005 1 100
;
RUN;

DATA table2;
  SET table1;
  UniqueKey = record_desc || record_id;
RUN;

PROC SUMMARY data = table2 NWAY MISSING;
  class UniqueKey record_desc record_id;
  var response;
  output out=table3(drop = _FREQ_ _TYPE_) sum=;
RUN;
5
  • I'm curious (as Chris is below) why you create UniqueKey? What's the problem you're solving? Commented Oct 13, 2014 at 16:20
  • I'm thinking I must have asked the wrong question, as this one doesn't make any sense. I'm going to go look back at the code and try to work out what I didn't understand (I'm maintaining code I did not write and I remembered something odd similar to this) Commented Oct 13, 2014 at 21:19
  • 1
    This question appears to be off-topic because it is about a trivial issue due to a mis-understanding of some other code. It is of no value to others. (THIS IS MY QUESTION, it cannot be salvaged) Commented Oct 15, 2014 at 21:34
  • I assume you can't delete it bc of the answer? Commented Oct 15, 2014 at 21:35
  • You can flag your question for a moderator, if you feel like it; they might delete it for you. Or you could ping Chris below and ask him to delete his answer; both of those things would allow you to delete the question. Commented Oct 15, 2014 at 21:42

1 Answer 1

2

You can summarise by record_desc and record_id (see class statement below) without creating a concatenation of the two columns. What made you think you couldn't?

PROC SUMMARY data = table1 NWAY MISSING;
  class record_desc record_id;
  var response;
  output out=table4(drop = _FREQ_ _TYPE_) sum=;
RUN;


proc compare 
    base=table3
    compare=table4;
run;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.