BookmarkSubscribeRSS Feed
Jarvin99
Obsidian | Level 7

I want to assign deciles for tweets within each publishday. How can I do it?

Below is my code:

proc sort data=abc.twitter;
by publishday tweets;
run;

data try2;
set abc.twitter;
keep publishday tweets;
run;


proc rank data=try2 groups=10 out=try2;
var tweets;
ranks decile;
run;

 

The result I get is only 8 ranks instead of 10 ranks each day. I use proc freq to check out the number of ranks within each day. But only 1,3,4,5,6,7,8,9 are shown, and rank 0 and rank 2 are missing.

proc freq data=try;
table decile;
by publishday;
run;

 

Thank you.

4 REPLIES 4
Reeza
Super User
Check your data for duplicates.
Jarvin99
Obsidian | Level 7

No. I just checked. I have unique firm-date data for tweets for a firm on a day. Now, it becomes only 8 ranks after I rerun the same codes. Really don't know why the results are inconsistent.

PaigeMiller
Diamond | Level 26

@Jarvin99 wrote:

No. I just checked. I have unique firm-date data for tweets for a firm on a day. Now, it becomes only 8 ranks after I rerun the same codes. Really don't know why the results are inconsistent.


The duplicates you need to check for are in the number of tweets, not in the unique publishday

 

Another possibility why you are getting only 8 ranks is because there is only 8 data points for a unique publishday

--
Paige Miller
Reeza
Super User

Aren't tweets text data? How are deciles being calculated for that? Or should it be based on time of day for the tweets?

 

You have your deciles on the variable tweets. You're saying the variable tweets doesn't have any duplicates? So no retweets in the data?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 583 views
  • 0 likes
  • 3 in conversation