☑ This topic is solved.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-11-2022 08:39 PM
(1079 views)
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.
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your feedback.
Is there any way to do it immediately from the CSV file?
Is there any way to do it immediately from the CSV file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;