Hi @luvscandy27
Stealing the part of the sample code from @A_Kh, here is one way how you can get what you looking for
/* Create sample data */
data have;
infile cards dlm=',' truncover;
length Chararacteristic $100;
input Chararacteristic;
cards;
White only:,
Below poverty,
At or above poverty,
Black or African American only:,
Below poverty,
At or above poverty,
Hispanic or Latino:,
Below poverty,
At or above poverty
;
run;
/* Create a Format that covers all sub-categories of interest regardless of their main characteristics */
proc formats lib=work;
value $subs
'Below poverty' = '*'
'At or above poverty' = '*'
;
run;
data want (DROP=Chararacteristic);
length main_char $40 sub_char $20;
retain main_char;
set have;
if (PUT(Chararacteristic,$subs.)='*') then sub_char = Chararacteristic;
else main_char = Chararacteristic;
if sub_char ne ''; /* Remove header row (Main_char only) */
run;
Hope this helps
... View more