BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gladis6680
Obsidian | Level 7

Thank you so much !!!

Gladis6680
Obsidian | Level 7

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 GETTINGWANT
Nestea Tea Cool Fridge Pack 12/355 MlFridge PackNestea Tea Cool Fridge Pack
Tea Traditional Herbal Variety Pack 6/28 CtVariety PackTea Traditional Herbal Variety Pack
Tea Herbal Apple Cranberry 6/28 CtApple CranberryTea Herbal Apple Cranberry
Nestea Tea Green W/Lemon 12/500 MlGreen W/LemonNestea Tea Green W/Lemon
Crystal Apple Low Calorie (20058336320846) 2/500 GrApple Low Calorie (20058336320846)Crystal Apple Low Calorie (20058336320846)
Drink Juice Cocktail Cranberry 12/1 LtDrink Juice  CranberryDrink Juice Cocktail Cranberry
Juice Cranberry Cocktail Plastic 24/300 MlJuice Cranberry  PlasticJuice Cranberry Cocktail Plastic
Juice Cranberry Cocktail Plastic Portion Cup (50058056200368) 96/114 MlJuice 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)
Ksharp
Super User

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);

Gladis6680
Obsidian | Level 7

thank you very much, that worked!!!!

Gladis6680
Obsidian | Level 7

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 GrCrystal Apple Low Calorie
Juice Cranberry Cocktail Plastic Portion Cup (50058056200368) 96/114 MlJuice Cranberry Cocktail Plastic Portion Cup
Juice Cranberry Cocktail Tetra Slim 12/1 Lt (10056412503629)Juice Cranberry Cocktail Tetra Slim
Ksharp
Super User
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;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 20 replies
  • 3296 views
  • 6 likes
  • 5 in conversation