BookmarkSubscribeRSS Feed
ksmielitz
Quartz | Level 8

I conducted a chi-sq for my variables and got the following results:

 

Frequency
Percent
Row Pct
Col Pct
Table of lowSD by PBClow
lowSD PBClow
0 1 Total
0
32
22.70
66.67
30.48
16
11.35
33.33
44.44
48
34.04
 
 
1
73
51.77
78.49
69.52
20
14.18
21.51
55.56
93
65.96
 
 
Total
105
74.47
36
25.53
141
100.00

 

 

Which is great. Now I need to write the code to create NEW variables to represent the (0,0), (0,1), (1,0), and (1,1)...so that when I run a proc freq I would get something resembling:

 

(0,0) variable 1: 32

                      0: 109

(0,1) variable 1: 16

                      0: 125

(1,0) variable 1: 73

                      0: 68

(1,1) variable 1: 20

                      0: 121

 

My current code is this: (and I get all of my values in the 0 on the proc freq (see below the code)

*Two by two combo of SD and PBC;
if PBClow=1 and SDlow=1 then LowLow = 1; else lowlow =0;
if PBChigh=1 and SDhigh=1 then HighHigh = 1; else highhigh =0;
if PBClow =1 and SDhigh=1 then Compare = 1; else compare=0;
if PBChigh =1 and SDlow=1 then HighLow = 1; else highlow=0;

 

SAS Output
The FREQ Procedure
LowLow Frequency Percent Cumulative
Frequency
Cumulative
Percent
0 141 100.00 141 100.00


HighHigh Frequency Percent Cumulative
Frequency
Cumulative
Percent
0 141 100.00 141 100.00


Compare Frequency Percent Cumulative
Frequency
Cumulative
Percent
0 141 100.00 141 100.00


HighLow Frequency Percent Cumulative
Frequency
Cumulative
Percent
0 141 100.00 141 100.00
Thanks in advance for any help you can provide!
Kate
2 REPLIES 2
PaigeMiller
Diamond | Level 26

@ksmielitz wrote:

I conducted a chi-sq for my variables and got the following results:

 

Frequency
Percent
Row Pct
Col Pct
Table of lowSD by PBClow
lowSD PBClow
0 1 Total
0
32
22.70
66.67
30.48
16
11.35
33.33
44.44
48
34.04
 
 
1
73
51.77
78.49
69.52
20
14.18
21.51
55.56
93
65.96
 
 
Total
105
74.47
36
25.53
141
100.00

 

 

Which is great. Now I need to write the code to create NEW variables to represent the (0,0), (0,1), (1,0), and (1,1)...so that when I run a proc freq I would get something resembling:

 

(0,0) variable 1: 32

                      0: 109

(0,1) variable 1: 16

                      0: 125

(1,0) variable 1: 73

                      0: 68

(1,1) variable 1: 20

                      0: 121

I think you have a better choice than writing the code that comes next and then trying to debug it. If you create an output data set from PROC FREQ, you have the table you want, described just above, with just a little less difficult programming. Let PROC FREQ do most of the work for you.

--
Paige Miller
Reeza
Super User
Look at the LIST option on the TABLES statement.

Table x * y / list out=want;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 2 replies
  • 794 views
  • 2 likes
  • 3 in conversation