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

Hi Friends - i have question and need help if someone can please...!!!

I have 8 variables and more than 1 million records in one sas dataset. I am concern about two variable "store" and "item". in this millions of records i have duplicates records for both store and item (of course not same number of duplicates records for both variables). both are numeric in type of data. I want to counts how many multiple "item" are there for unique "store" number?

How can i do this?

Thanks in advance...!!!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

1 million records really isn't a lot.

Try outputting it to a dataset and then checking the dataset.

proc freq data=mydata noprint;

tables store*item /out=check_items_per_store;

run;

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

Not sure I quite get what you want.

If you want to see counts for the combinations of value for these variable you could use PROC FREQ.

proc freq data=mydata ;

tables store*item ;

run;

So if STORE #1 has 15 observations for ITEM A then the count will be 15.

PGStats
Opal | Level 21

Or maybe you want to know how many distinct items are associated with each store? For that, you could use:

   

proc sql;

select store, count(distinct item) as nbItems

from myData

group by store;

quit;

PG

PG
woo
Barite | Level 11 woo
Barite | Level 11

Tom - i did run it but giving so big output that is taking too much time open up.

PGStats - query giving same constant value for Item

I might not have represented my question very well i guess.

i want:

if Store "123456" has 3 Item (6578, 8766, 1256) and Sore "789101" has 5 item (6655, 2233,1467, 4545, 3333) then output would be like;

Store       Item

123456    6578

               8766

               1256

789101    6655

               2233

               1467

                4545

                3333

Thanks!

Tom
Super User Tom
Super User

If you just want to list the data then use PROC PRINT.  If the same combination (for example Store=123456 and Item=6578) can appear multiple times in your data then sort it using the NODUPKEY option.

proc sort data=have (keep=store item) out=want nodupkey ;

   by store item;

run;

proc print data=want ;

   by store;

   id store ;

  var item;

run;

Reeza
Super User

1 million records really isn't a lot.

Try outputting it to a dataset and then checking the dataset.

proc freq data=mydata noprint;

tables store*item /out=check_items_per_store;

run;

woo
Barite | Level 11 woo
Barite | Level 11

Thanks Reeza, TOM, PGStats...

Reeza - it worked grt...!!!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 6 replies
  • 1589 views
  • 6 likes
  • 4 in conversation