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.
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
The second is very easy in SQL:
proc sql;
create table want as
select count(*) as count_of_tweets
from have
where date ge '20jan2017'd;
quit;
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;
For the first question, it would be how many posts for each year.
@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.
The second is very easy in SQL:
proc sql;
create table want as
select count(*) as count_of_tweets
from have
where date ge '20jan2017'd;
quit;
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
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.
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.