DATA Step, Macro, Functions and more

PROC FREQ or PROC TABULATE for complex table

Reply
Frequent Contributor
Posts: 142

PROC FREQ or PROC TABULATE for complex table

[ Edited ]

Hi all,

 

Could you please say how to implement Proc Freq for the following case. I have the table below:

1.jpg

and I need to build the following statistics (frequencies):

2.jpg

 

What shoult be the format of PROC FREQ? Or should it be PROC TABULATE? I am looking for a decision in several steps but can it be sorted out in one?

I have attached the datalines for your conveniencies:

data test;
	length Patient $1 Examination $7 Visit1Finding	Visit2Finding Cohort $1;
	infile datalines dlm='	';
	input Patient Examination Visit1Finding	Visit2Finding Cohort;
datalines;
1	SKIN	N	N	1
1	ABDOMEN	N	N	1
2	SKIN	Y	N	2
2	ABDOMEN	N	Y	2
3	SKIN	N	Y	1
3	ABDOMEN	N	Y	1
4	SKIN	N	Y	2
4	ABDOMEN	N	Y	2
5	SKIN	Y	Y	1
5	ABDOMEN	N	Y	1
6	SKIN	N	Y	2
6	ABDOMEN	N	Y	2
7	SKIN	N	Y	1
7	ABDOMEN	N	Y	1
8	SKIN	N	Y	1
8	ABDOMEN	N	Y	1
;
run;

Thank you. 

Super User
Posts: 5,518

Re: PROC FREQ or PROC TABULATE for complex table

Posted in reply to DmytroYermak

How does Visit2Finding get utilized in constructing the table?

 

PROC FREQ can give you something quick and dirty, not at all fancy and only similar to what you asked for:

 

proc freq data=have;

tables examination * visit1Finding * cohort / missing list;

run;

 

You might add Visit2Finding in there somewhere, depending on what it is supposed to be used for.

 

For anything fancier, you probably need to switch to PROC TABULATE.

Frequent Contributor
Posts: 142

Re: PROC FREQ or PROC TABULATE for complex table

[ Edited ]
Posted in reply to Astounding

I have received the following table:

3.jpg

but badly need exactly the one below (. Is it possible to use Proc Report and what is the algorythm for it?

2.jpg

Super User
Posts: 11,343

Re: PROC FREQ or PROC TABULATE for complex table

Posted in reply to DmytroYermak

It is best to post example data in a form that can be used for demonstrating code. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Ask a Question
Discussion stats
  • 3 replies
  • 123 views
  • 0 likes
  • 3 in conversation