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

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 3 replies
  • 698 views
  • 4 likes
  • 4 in conversation