SAS lookup coding from an external reference

Reply
Occasional Learner
Posts: 1

SAS lookup coding from an external reference

I am trying code certain retailer chains, predefined in my system from some store names. The store names contain the type of retailer, wherefrom i need to code the retailer chain. For example, there are multiple retail chains like Pick and Pay Mini, Pick and Pay Super, Shoprite, Shoprite Liqor etc. 

 

The store names will by like PNP Mini ABC, Shoprite Liq XYZ and so on. So basically I need to code such that the system when comes across key words like shoprite it'll code it as SPR, for Shoprtie Liq it'll code SPL and so on, according to the store name

 

How can it read through strings and look for key words and throw appropriate code for it?

Super User
Posts: 7,447

Re: SAS lookup coding from an external reference

To check for substrings or words contained in a string, look for the index() or findw() functions.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 5,388

Re: SAS lookup coding from an external reference

If you have additional and similar requirements, you might want to look at SAS Data Management Studio, which has this as a core functionality.

Data never sleeps
Ask a Question
Discussion stats
  • 2 replies
  • 232 views
  • 0 likes
  • 3 in conversation