Hi everybody The code below is running as it should, it just fills up a lot of space 🙂 I have 4 variables in which I use the function prxchange to make certain expression similar on all observations and for the 4 variables and then in the end use the CATX function to rearrange the final variables as I want them to be. I would like to just write the code once, and not writing it 4 times because of the 4 variables. I hope someone can help me with that. Thanks in advance. %let kø =NEW_QUEUE; %put &kø; %let koe =QUEUE; %put &koe; %let trin =SAGSTRIN; %put &trin; %let strin =SAGSTRINNAVN; %put &strin; data &navn (drop= &kø &kø._2 &kø._3 &kø._4 XREF_clean1 &koe &koe._2 &koe._3 &koe._4 XREF_clean2 &trin &trin._2 &trin._3 &trin._4 XREF_clean3 &strin &strin._2 &strin._3 XREF_clean4 rename =(&kø._5=NEW_QUEUE &koe._5=QUEUE &trin._5=SAGSTRIN &strin._4=SAGSTRINNAVN Ansvarlig=Ini); set wfstat.sagstider (keep=&varliste); length &kø &kø._2 &kø._3 &kø._4 &kø._5 &koe &koe._2 &koe._3 &koe._4 &koe._5 &trin &trin._2 &trin._3 &trin._4 &trin._5 &strin &strin._2 &strin._3 &strin._4 $ 60; start_date =datepart(trin_start); slut_date =datepart(wf_slut); Md_afslut =month(slut_date); Year =year(slut_date); *Changing XREF step (NEW_QUEUE), so it's the same for all oberservations; &kø._2 = left(prxchange('s/X-REF|NY XRF|Ny X-Ref|Ny XRef|X-ref|NXR|Ny XR/XREF/oi',-1,trim(upcase(&kø)))); &kø._3 = left(prxchange('s/[(]|[)]/ /i',-1,trim(upcase(&kø._2)))); if prxmatch("m/XREF/oi",&kø._3) then XREF_clean1="XREF"; &kø._4 = left(prxchange('s/XREF//i',-1,trim(upcase(&kø._3)))); &kø._5 = CATX(" - ",XREF_clean1,propcase(&kø._4)); *Changing XREF step (QUEUE), so it's the same for all oberservations; &koe._2 = left(prxchange('s/X-REF|NY XRF|Ny X-Ref|Ny XRef|X-ref|NXR|Ny XR/XREF/oi',-1,trim(upcase(&koe)))); &koe._3 = left(prxchange('s/[(]|[)]/ /i',-1,trim(upcase(&koe._2)))); if prxmatch("m/XREF/oi",&koe._3) then XREF_clean2="XREF"; &koe._4 = left(prxchange('s/XREF//i',-1,trim(upcase(&koe._3)))); &koe._5 = CATX(" - ",XREF_clean2,propcase(&koe._4)); *Changing XREF step (SAGSTRIN), so it's the same for all oberservationst; &trin._2 = left(prxchange('s/X-REF|NY XRF|Ny X-Ref|Ny XRef|X-ref|NXR|Ny XR/XREF/oi',-1,trim(upcase(&trin)))); &trin._3 = left(prxchange('s/[(]|[)]/ /i',-1,trim(upcase(&trin._2)))); if prxmatch("m/XREF/oi",&trin._3) then XREF_clean3="XREF"; &trin._4 = left(prxchange('s/XREF//i',-1,trim(upcase(&trin._3)))); &trin._5 = CATX(" - ",XREF_clean3,propcase(&trin._4)); *Changing XREF step (SAGSTRINNAVN), so it's the same for all oberservations; &strin._2 = left(prxchange('s/X-REF|NY XRF|Ny X-Ref|Ny XRef|X-ref|NXR|Ny XR/XREF/oi',-1,trim(upcase(&strin)))); if prxmatch("m/XREF/oi",&strin._2) then XREF_clean4="XREF"; &strin._3 = left(prxchange('s/XREF//i',-1,trim(upcase(&strin._2)))); &strin._4 = CATX(" - ",XREF_clean4,propcase(&strin._3)); format start_date slut_date date9.; run;
... View more