Hello,
I have a CSV file similar to this one:
;Red;Blue;Green;Yellow;Black Group 1;472;124;577;242;367 Group 2;272;97;715;252;255 Group 3;246;233;121;144;209
And I would like to get a bar chart such as the following, then do a chi-squared test:
I can't find a solution by browsing the documentation; could someone please help me?
Thanks.
data have;
infile cards truncover dlm=';';
input group :$40. Red Blue Green Yellow Black;
cards4;
Group 1;472;124;577;242;367
Group 2;272;97;715;252;255
Group 3;246;233;121;144;209
;;;;
proc transpose data=have out=want;
by group;
var _numeric_;
run;
proc sgplot data=want;
vbar _name_/group=group response=col1 groupdisplay=cluster;
xaxis label=' ';
yaxis label=' ';
run;
proc freq data=want;
table _name_*group/chisq ;
weight col1;
run;
data have;
infile cards truncover dlm=';';
input group :$40. Red Blue Green Yellow Black;
cards4;
Group 1;472;124;577;242;367
Group 2;272;97;715;252;255
Group 3;246;233;121;144;209
;;;;
proc transpose data=have out=want;
by group;
var _numeric_;
run;
proc sgplot data=want;
vbar _name_/group=group response=col1 groupdisplay=cluster;
xaxis label=' ';
yaxis label=' ';
run;
proc freq data=want;
table _name_*group/chisq ;
weight col1;
run;
@wespol wrote:
Thank you for your feedback.
Is there any way to do it immediately from the CSV file?
SAS basically works with SAS data sets. So read an external file, such as CSV, into a data set and then do analysis or other actions with that data set.
Sure .It is easy to read CSV into SAS .
proc import datafile='c:\temp\have.csv' out=have dbms=csv replace;
delimiter=';';
guessingrows=max;
run;
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.
Ready to level-up your skills? Choose your own adventure.