Hi all,
I'm attaching an example extract file. Basically all I have is procedure codes which have a certain section or not as shown by section number variables. If a section is present for that procedure code, there is a number similar to section number variable below the variable, otherwise its blank. For instance, for the first procedure code, A9279, I have section 18, 19, 20, 21 and 29 and other sections are blank. Similarly, for procedure code G0108, sections present are 3,31 and 103 and so on. What i'm looking is following output-
procedure_code section_numbers
A9279 18,19,20,21,29
G0108 3,31,103
G0109 3,31,103
G0151 19, 40
Thanks for your help!
want = catx(",", of section_3--section_103);
Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.
This link: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... has instructions on how turn a SAS data set into data step code that can be pasted into the forum or attach as a plain TXT file to allow us to test code and such.
Ok, here is the data you can read in sas. I already mentioned the desired output as above. Thanks so much!
data WORK.have;
infile datalines dsd truncover;
input Procedure_Code:$5. section_3:$1. section_5:$1. section_7:$1. section_12:$2. section_13:$1. section_15:$1. section_17:$2. section_18:$2. section_19:$2. section_20:$2. section_21:$2. section_22:$2. section_23:$1. section_25:$1. section_26:$2. section_2
8:$2. section_29:$2. section_30:$2. section_31:$2. section_32:$2. section_40:$2. section_65:$2. section_68:$1. section_85:$1. section_96:$2. section_97:$1. section_102:$1. section_103:$3.;
datalines4;
A9279,,,,,,,,18,19,20,21,,,,,,29,,,,,,,,,,,
G0108,3,,,,,,,,,,,,,,,,,,31,,,,,,,,,103
G0109,3,,,,,,,,,,,,,,,,,,31,,,,,,,,,103
G0151,,,,,,,,,19,,,,,,,,,,,,40,,,,,,,
G0152,,,,,,,,,19,,,,,,,,,,,,40,,,,,,,
;;;;
want = catx(",", of section_3--section_103);
Thanks so much! I knew of CATX function but was not sure how will it take care of blanks. But it seems your code took care of that.
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.
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.