BookmarkSubscribeRSS Feed
dparnes
Calcite | Level 5

Hi,

I need to reverse a table in SAS.

For example I have a list of stores (1, ,2, 3, ..., 2000) on the first column and for each store I have a list of customers (1, ,2, 3, ..., 2000) in the following columns, but this list is limited to up to 12 customers (random number of customers per store).

Now I need to reverse the story, i.e. to build a list of costumers sorted from 1 to 2000 on the first column, and for each customer to find from the original table a list of corresponding stores.

How can I do that in SAS?

Thank you!

1 REPLY 1
art297
Opal | Level 21

Not sure I understand what you have.  Does the following approximate what your file looks like for the first two stores?:

Store Cust1 Cust2 Cust3 Cust4 Cust5 Cust6 Cust7 Cust8 Cust9 Cust10 Cust11 Cust12

1        24     2        5        6        1000  50      80      900     901    902      903     700

2        54     22      58      76       25     90      70      800     801    802      803     600

and you want to end up with a file that looks like?:

Cust Store

24    1

2     1

5      1

6      1

etc.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1347 views
  • 0 likes
  • 2 in conversation