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

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
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

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
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

Thanks Reeza, TOM, PGStats...

Reeza - it worked grt...!!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 779 views
  • 6 likes
  • 4 in conversation