BookmarkSubscribeRSS Feed
mmjohnson
Calcite | Level 5

Hi,

 

I am using SAS 9.4. I have a variable yes/no response options but all of answers were yes. I am using ods tables in proc freq to export the output to a data set and them export it (with DDE) to excel. My excel table is set up with both Yes and No so I should have Yes = 100% and No=0% in excel. Except SAS in the proc freq ods command only exports the 100%. Is there a way for me to export the output in a new data set that contains both Yes and No?

 

Thanks.

2 REPLIES 2
Kurt_Bremser
Super User

PROC FREQ will only report (and output) values that are actually present in the dataset. If you need to have other values in your output dataset, you could create a default dataset containing all values and then do a join to complete your output dataset

data ynresponse;
input response $3.;
cards;
no
yes
;
run;

data wanted_result;
merge
  result (in=a)
  ynresponse (in=b)
;
by response;
if not b then count = 0; * avoids missing values;
run;
Ksharp
Super User
data have;
input response $3.;
cards;
yes
yes
yes
yes
;
run;
data temp;
response='no';
run;

data want;
 set have(in=ina) temp;
 weight=ina;
run;
proc freq data=want;
table response ;
weight weight/zeros;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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