I want to input this information into SAS
So far I have
data RCT;
input treatment $ outcome $;
I'm not sure how to enter the information under datalines, and I'm not sure if I have the input statement in correctly. How do I go about doing this?
How about this...
data example;
do trt = 'Placebo','Drug';
do outcome = 'Sick','Well';
input count @;
output;
end;
end;
stop;
datalines;
30 10
15 40
;;;;
run;
proc print;
run;
How about this...
data example;
do trt = 'Placebo','Drug';
do outcome = 'Sick','Well';
input count @;
output;
end;
end;
stop;
datalines;
30 10
15 40
;;;;
run;
proc print;
run;
It may help to decide/ show what the output data set looks like or tell us how you expect to use the data.
This looks like a summary table where the numbers are likely counts of the outcome.
If this were my data, and that is all there is perhaps:
data want; input treatment $ outcome $ count; datalines; Placebo Sick 30 Placebo Well 10 Drug Sick 15 Drug Well 40 ;
In many forms of analysis a variable that indicates the number of results, using either a WEIGHT or FREQ statement will use the count.
Example:
Proc freq data=want; tables treatment*outcome/ chisq expected; weight count; run;
Which generates a table of the counts comparing treatment and outcome, with percentages, the expected count if there were no differences in the distribution of outcomes between the two treatments and a chi-squared test for similarity of distribution (not similar in this case).
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.