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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1113 views
  • 2 likes
  • 3 in conversation