How to create two tables in SAS from one database. Thanks in advance.
The question goes like this: "Create a set that contains all incident variables (non-cumulative cases): ANGINA, HOSPMI, HYPERTEN, MI_FCHD, STROKE. Create a sum that includes incidents. Conditionally output the data to two different SAS tables: one that has subjects with 1 or more incidents and one with subjects with no incidents."
What is the principle to summarize the data in order to derive two tables from them: "without incidents" and "1 or more inc."
UPD. How to summarize this data horizontally to get the second table "No incidents (0)" ?
This depends a lot on your data structure and how you can identify records.
You can direct output to two different data sets relatively easily.
data females males other; * list of data sets that will be created;
set sashelp.class; *input data;
*conditionally assign to different output data sets;
if sex = 'F' then output females;
else if sex = 'M' then output males;
else output Other;
run;
@aether wrote:
How to create two tables in SAS from one database. Thanks in advance.
The question goes like this: "Create a set that contains all incident variables (non-cumulative cases): ANGINA, HOSPMI, HYPERTEN, MI_FCHD, STROKE. Create a sum that includes incidents. Conditionally output the data to two different SAS tables: one that has subjects with 1 or more incidents and one with subjects with no incidents."
What is the principle to summarize the data in order to derive two tables from them: "without incidents" and "1 or more inc."
Please post 2 sets of sample data showing what you have and what you want.
data dataset;
infile '\path\dataset.dat' FIRSTOBS = 2 DSD;
input /*other variables*/ RANDID ANGINA HOSPMI MI_FCHD STROKE HYPERTEN;
keep RANDID ANGINA HOSPMI MI_FCHD HYPERTEN STROKE;
run;
ods html close;
ods html file = "\path\output.html";
/*here, it seems to me, there should be a horizontal summation by RANDID*/
data NOINC INC;
set work.dataset;
if /*sum*/ = 0 then output NOINC;
else if /*sum*/ = >1 then output INC;
run;
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!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.