Thank you so much !!!
Hi there,
I had another question regarding this. I have slightly modified this by just added the other units of measurement.
want=prxchange('s/\S+\s*(Ea|Ct|Kg|Gr|Lt|Lb|Ml|Ga|Oz|Fl|Ga|Each|L)\b//i',-1,have);
But then I get the below table, is it possible to make the above code case sensitive, meaning it only takes out 'Ea' and not 'ea'
I would appreciate your help, Thank you
HAVE | GETTING | WANT |
Nestea Tea Cool Fridge Pack 12/355 Ml | Fridge Pack | Nestea Tea Cool Fridge Pack |
Tea Traditional Herbal Variety Pack 6/28 Ct | Variety Pack | Tea Traditional Herbal Variety Pack |
Tea Herbal Apple Cranberry 6/28 Ct | Apple Cranberry | Tea Herbal Apple Cranberry |
Nestea Tea Green W/Lemon 12/500 Ml | Green W/Lemon | Nestea Tea Green W/Lemon |
Crystal Apple Low Calorie (20058336320846) 2/500 Gr | Apple Low Calorie (20058336320846) | Crystal Apple Low Calorie (20058336320846) |
Drink Juice Cocktail Cranberry 12/1 Lt | Drink Juice Cranberry | Drink Juice Cocktail Cranberry |
Juice Cranberry Cocktail Plastic 24/300 Ml | Juice Cranberry Plastic | Juice Cranberry Cocktail Plastic |
Juice Cranberry Cocktail Plastic Portion Cup (50058056200368) 96/114 Ml | Juice Cranberry Plastic Portion Cup (50058056200368) | Juice Cranberry Cocktail Plastic Portion Cup (50058056200368) |
Juice Cranberry Cocktail Tetra Slim 12/1 Lt (10056412503629) | Juice Cranberry Tetra Slim (10056412503629) | Juice Cranberry Cocktail Tetra Slim (10056412503629) |
Remove ' i ' modification.
prxchange('s/\S+\s*(Ea|Ct|Kg|Gr|Lt|Lb|Ml|Ga|Oz|Fl|Ga|Each|L)\b//i',-1,have);
->
prxchange('s/\S+\s*(Ea|Ct|Kg|Gr|Lt|Lb|Ml|Ga|Oz|Fl|Ga|Each|L)\b//',-1,have);
thank you very much, that worked!!!!
So sorry to ask so many questions, but I am not so familiar with the prxchange function. Is it possible to also take the information in the brackets with the number. I tried different possibilities, but its not working. Thank you very much
prxchange('s/\S+\s*(Ea|Ct|Kg|Gr|Lt|Lb|Ml|Ga|Oz|Fl|Ga|Each|L)\b//',-1,have);
HAVE | WANT |
Crystal Apple Low Calorie (20058336320846) 2/500 Gr | Crystal Apple Low Calorie |
Juice Cranberry Cocktail Plastic Portion Cup (50058056200368) 96/114 Ml | Juice Cranberry Cocktail Plastic Portion Cup |
Juice Cranberry Cocktail Tetra Slim 12/1 Lt (10056412503629) | Juice Cranberry Cocktail Tetra Slim |
data have;
input have $80.;
p=prxmatch('/\S+\s*(Ea|Ct|Kg|Gr|Lt|Lb|Ml|Ga|Oz|Fl|Ga|Each|L)\b/',have);
if p>0 then want= scan(substr(have,1,p-1),1,'(');
cards;
Crystal Apple Low Calorie (20058336320846) 2/500 Gr
Juice Cranberry Cocktail Plastic Portion Cup (50058056200368) 96/114 Ml
Juice Cranberry Cocktail Tetra Slim 12/1 Lt (10056412503629)
;
proc print;run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: