BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
westbestern
Obsidian | Level 7

I want to input this information into SAS

h.PNG

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?

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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;

Screenshot 2021-10-06 143018.png

View solution in original post

3 REPLIES 3
Reeza
Super User
You have two column headers in your INPUT but three in the table....
Type the data below the INPUT statement separated by a single space with 4 semicolons to end the lines. Note that $ indicates a character variable, ie values like A, B, C. If you read in your numbers as characters you cannot do math on those fields.


data want;
input trt sick well;
cards;
1 5 6
2 5 30
;;;;;
run;
data_null__
Jade | Level 19

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;

Screenshot 2021-10-06 143018.png

ballardw
Super User

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).

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1142 views
  • 4 likes
  • 4 in conversation