DATA Step, Macro, Functions and more

How to make single column from different variables

Reply
Contributor
Posts: 64

How to make single column from different variables

Hi Experts ,

I havea a data set that the values are showed like different raws and I want to make that raws in a single column .No problem if the claim and suffixs shows multiple times 

the data Have 

Claim Suffix  ICD10A  ICD10B  ICD10C ICD10D  ICD10E
12589 1         vvg         ijk           ghy        ilk            opl
12589 2          rty         ilk            rtr         erd           owe


data want

 Claim Suffix   ICD10
12589   1           vvg
12589   1           ijk
12589   1          ghy
12589   1         ilk
12589   1         opl
12589   2        rty
12589   2        ilk
12589  2        rtr
12589  2         erd
12589  2      owe

How to proceed with this scenario Please advice

Super User
Posts: 19,822

Re: How to make single column from different variables

Posted in reply to ambadi007
Contributor
Posts: 22

Re: How to make single column from different variables

[ Edited ]
Posted in reply to ambadi007

Would something like this work for your situation?

 

data Some;
input Claim Suffix A $ B $ C $ D $ E $;
datalines;
12589 1 vvg ijk ghy ilk opl
12589 2 rty ilk rtr erd owe
;
run;

Data Some2;
Set Some;
Array New A--E;
Do _N_ = 1 to dim(New);
ICD10 = New(_N_);
Output;
End;
Keep Claim Suffix ICD10;
Run;

 

 

Super User
Posts: 11,343

Re: How to make single column from different variables

Posted in reply to jdwaterman91

@jdwaterman91 minor suggestion:

Data Some2;
   Set Some;
   Array New A--E;
   Do _N_ = 1 to 5;
      ICD10 = New(_N_);
      if not missing(ICD10) then Output;
   End;
   Keep Claim Suffix ICD10;
Run;

@ambadi007 did not indicate whether or not the data may sometimes only have fewer than 5 codes, or possibly no codes at all, and what the output for those cases might be. I am assuming that a row with a missing ICD10 is pretty useless and excluding them.

 

Ask a Question
Discussion stats
  • 3 replies
  • 114 views
  • 1 like
  • 4 in conversation