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

Hello,

 

I have some two problems asking as followed while using SAS.

 

1. To find out how many times for each year.

2. To find out how many times after JAN202017. 

 

  1. How many of tweets has Mr. President made each year (give total number tweets for each year?)
  2. How many of tweets has Mr. President made after he became president (find this date online)? *(JAN.20.2017)

 

The data set is as followed in the photo (not the full data set shown).

 

Source                                 Text                          Date                       Time                       Retweet_count

Twitter for iphone           Goodmorning...     24MAR2019                 12:01:44                        76002

Twitter for iphone           .....................         24MAR2019                 12:01:44                        76002

Twitter for iphone           ......................        24MAR2019                 12:01:44                        76002

1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5
andreas_lds
Jade | Level 19

For the fist question: do you want to specify the year, or do you need the number for each year you have?

For the later try:

proc summary data=have nway;
  class Date;
  format Date year4.;
  output out=counted(drop=_type_ rename=(_freq_=count)):
run;

 

nimedina
Calcite | Level 5

For the first question, it would be how many posts for each year.

andreas_lds
Jade | Level 19

@nimedina wrote:

For the first question, it would be how many posts for each year.


Then the code i posted should be a solution for the first question. I have, of course, assumed, that the date you have is a proper sas date and not a string.


akanshya142
Calcite | Level 5

1. You can use group by for the same:

 

proc sql;

create table want as 

select year(date) as yr, count(*) as cnt_tweets from have

group by yr;

quit;

 

The solution of 2 has been given earlier

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 742 views
  • 1 like
  • 4 in conversation