filename in 'c:\temp\values.sas'; /*original sas code*/
filename out 'c:\temp\new_values.sas'; /*processed sas code*/
data _null_;
infile in;
file out;
input;
if first(left(_infile_)) in ('.' '0' '1' '2' '3' '4' '5' '6' '7' '8' '9')
and findc(_infile_,"=") and findc(_infile_,"'") then
_infile_=prxchange("s/'\d+\s+/'/",1,_infile_);
put _infile_;
run;
*THIS* is the type of shenanigans I was talking about.
THANK YOU!!!
To everyone else - you all brought up great points and some suggestions were "better" than the type of solution I was looking for. Unfortunately, given the constraints I'm working with a quick and dirty script was the best/only viable solution.
Thanks everyone!
It would be much easer to edit the formats after they are created and then recreate the FMTLIB. You say they will run whatever you give them this should suffice. This example uses LIB=WORK.FORMATS you will need to change for permanent format library.
* what you have;
proc format;
VALUE TED_DONOR
.B = 'Unknown'
.C = 'Not answ/Inconsist'
1 = '1 HLA-identical sibling'
2 = '2 Syngeneic'
3 = '3 Related Donor, match status unknown'
4 = '4 Matched Unrelated Donor (MUD)'
31 = '31 HLA-matched other relative'
32 = '32 HLA-mismatched relative'
41 = '41 HLA matched unrelated'
42 = '42 HLA mismatched unrelated'
;
VALUE PTTXTYPE
1 = '(1) Allo only'
2 = '(2) Auto only'
3 = '(3) Allo transplant(s) then Auto(s)'
4 = '(4) Auto transplant(s) then by Allo(s)'
5 = '(5) Allo transplant(s) then DCI'
6 = '(6) Auto transplant(s) then Allo(s) then DCI'
;
VALUE TEDVSRES
1 = '1 TED'
2 = '2 CRF (RES)'
3 = '3 moved CRF (RES) to TED'
4 = '4 moved TED to CRF (RES)'
5 = '5 moved CTRM to TED'
6 = '6 Cellular Therapy Regenerative Medicine (CTRM, CTR)'
7 = '7 Auto no Consent'
8 = '8 moved TED to CTRM'
;
quit;
*this is the script you need insert in the process;
proc format lib=work.formats cntlout=cntlout;
quit;
data cntlin;
set cntlout;
if type eq 'N' then do;
if not missing(input(start,32.)) then do;
label = left(compress(substr(label,anyspace(label)),'09'x));
end;
end;
run;
proc format cntlin=cntlin fmtlib;
quit;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.