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
SAS Super FREQ
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.

 

 


 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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