BookmarkSubscribeRSS Feed
Guptashwe
Calcite | Level 5

we need to calculate the score for each day for each tweet. Where we have a word polarity sheet with score and a sheet with tweets data.

 

 

2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
Here's a previous posting https://communities.sas.com/t5/SAS-Programming/Perform-Sentiment-Analysis-Using-Base-advanced-Sas/td... on the topic that may get your started. If you have SAS Enterprise Miner, SAS Text Miner and SAS Sentiment Analysis tools, those might mean using a different approach.
Cynthia
Reeza
Super User

FYI - I've changed the subject in your thread to be more related to your question. 'Need help' is very vague and doesn't indicate the subject of your question. 

 

 

Here's a similar example of something I tried a while back for data analysis. 

https://github.com/statgeek/SAS-Tutorials/blob/master/text_analysis.sas

 

*Create sample data;
data random_sentences;
    infile cards truncover;
    informat sentence $256.;
    input sentence $256.;
    cards;
This is a random sentence
This is another random sentence
Happy Birthday
My job sucks.
This is a good idea, not.
This is an awesome idea!
How are you today?
Does this make sense?
Have a great day!
;
    ;
    ;
    ;

*Partition into words;
data f1;
    set random_sentences;
    id=_n_;
    nwords=countw(sentence);
    nchar=length(compress(sentence));

    do word_order=1 to nwords;
        word=scan(sentence, word_order);
        output;
    end;
run;

*Add happiness index and pos;

proc sql ;
    create table scored as 
    select a.*, b.happiness_rank, c.pos, c.pos1
    from f1 as a 
    left join ta.sentiment as b 
    on a.word=b.word 
    left join ta.corpus as c
    on a.word=c.word
    order by sentence, word_order;
quit;

*Calculate sentence happiness score;
proc sql;
create table sentence_sentiment as
select distinct sentence, sum(happiness_rank) as sentiment
from scored
group by id;
quit;

@Guptashwe wrote:

we need to calculate the score for each day for each tweet. Where we have a word polarity sheet with score and a sheet with tweets data.

 

 


 

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
  • 2 replies
  • 1641 views
  • 0 likes
  • 3 in conversation