turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Combining Continuous Variables per Observation

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-20-2016 08:31 AM

I have three continuous variables, tot_doc_fp, tot_nurse_fp, and tot_mid_fp. For my analysis, I want to know if any combination of the values of the three variables is greater than or equal to 2 for any of the observations, and then for what percentage of observations the combined value is greater than or equal to 2. I'm on version 9.4.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-20-2016 08:43 AM

data have;

tot_doc_fp=1;

tot_nurse_fp=1;

tot_mid_fp=1;

output;

tot_doc_fp=0;

tot_nurse_fp=0;

tot_mid_fp=0;

output;

run;

data want(keep=fraction);

set have end=the_end;

if sum(tot_doc_fp,tot_nurse_fp,tot_mid_fp) ge 2 then count_true+1;

if the_end then do;

fraction=count_true/_N_; output;

end;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-20-2016 09:29 AM

Does this take into account that any one of the variables could have a value higher than 2 by itself?

And how do I view the output? Nothing is showing up in my results viewer.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-20-2016 09:37 AM

the condition is that the sum of the variables is greater or equal 2, so any value can be on the input. In detail if one variable is ge 2 the condition is true, if you want something else, please specify your question.

The output fraction is stored in dataset want.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-20-2016 09:45 AM

I appreciate the code, but I'm still confused. The number I am getting is 0.5, but there are 135 observations, so that can't be correct.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-20-2016 09:52 AM

OK, th first part of my code creates a dummy dataset have with two observation. View this dataset.

In the next part i count the frequency and output the percentage. For one observation the condition holds true, for the other it does not. So the fraction is 0.5. I output this to the dataset want.

You need to provide more info or adapt the code for your case yourself.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-20-2016 09:41 AM

It is best practice here to provide some example data that covers all of your data cases and the desired results for that example data. If you have missing values, negative values, etc. examples should be included. Best is to follow instructions from here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... to create data step code that allows us to recreate your example data to test code against.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-21-2016 05:44 AM

Better post an example to explain your question and don't forget post the output either.