Hi,
I am very puzzled, I've ran the proc freq as art297 kindly suggested and used the the "/" to get an output data for these results, now I have to merge the true freq table with observed freq table. The problem is that when I do merge them only the first data set's full information shows. how can I fix this?
thanks
my code:
proc freq data=c10000.c10000_D1 ;
tables True_Class / out=c10000.D1;
tables Est_Class / out=c10000.D2;
tables True_class*Est_Class / out=c10000.D3;
Run;
data c10000.D1;
set c10000.D1;
obs=_n_;
run;
data c10000.d22;
set c10000.d2;
label count=Est_Frq percent=est_perc;
run;
data c10000.d11;
set c10000.d1;
label count=tru_Frq percent=tru_perc;
run;
data c10000.D22;
set c10000.D2;
obs=_n_;
run;
proc sort data=c10000.D1 out=c10000.D1; by obs;
run;
proc sort data=c10000.D2 out=c10000.D2; by obs;
run;
data c10000.Freqency;
merge c10000.D22 c10000.D11; by obs;
run;
proc print data=c10000.Freqency;
run;
The variables are being overwritten by the data set on the right in MERGE.
These statements need to be RENAME not LABEL
label count=Est_Frq percent=est_perc;
Plus you don't need a complete do nothing data step just to rename use data set options on MERGE statement.
HOWEVER, I think you could do this more easily with with ODS OUTPUT and ONE table statement for the crossed table. But I can't give you any details because I don't know what you want.
Thanks for the comment but RENAME does not work, LABEL does, I do not know why.
also I am attaching the files I am trying to merge.
D11 data file has these variables: True_Class tru_frq tru_perc obs
D22 data file has set_class est_frq est_perc obs
merging into:
FREQUNCY data file but the problem is after merging this data file has only these variables in them:
True_class tru_frq tru_perc obs
I don't know what I am doing wrong
thanks
Like DN, I don't know why you didn't just use ODS. Regardless, given that you have the same number of records in each file, and in the same order, why not combine them with:
PROC IMPORT OUT= WORK.d11
DATAFILE= "C:\art\d11.xls"
DBMS=xls REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
PROC IMPORT OUT= WORK.d22
DATAFILE= "C:\art\d22.xls"
DBMS=xls REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
PROC IMPORT OUT= WORK.frequency
DATAFILE= "C:\art\frequency.xls"
DBMS=xls REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
data want;
set frequency (rename=(count=freq_count
percent=freq_percent));
set d11 (keep=count percent
rename=(count=d11_count
percent=d11_percent));
set d22 (keep=count percent
rename=(count=d22_count
percent=d22_percent));
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!
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.