BookmarkSubscribeRSS Feed
Melk
Lapis Lazuli | Level 10

I have a really large dataset that looks like this:

 

ID   A B C -- ZZ A_new B_new C-new -- ZZ_new

1     0 1 1 --   1    1          1         0              0

..

..

 

 

I want to perform a test of agreement between all variables of the same name + the suffix

 

i.e.

 

proc freq data=dat;

     table A*A_new / agree;

     table B*B_new / agree;

..

run;

 

I dont think we can use an array to do a SAS procedure - but is there another way to do this without have to write down every variable name?

 

 

 

 

6 REPLIES 6
Melk
Lapis Lazuli | Level 10

Another importnat thing to note is that I only really care about p-values for the kappa statistics right now. Ideally, I could output to a dataset and then sort by p-value to get the variables that are significant. 

Reeza
Super User
I would recommend transposing your data so you can use a BY statement instead.
Melk
Lapis Lazuli | Level 10

so I converted to longitudinal, extra vairable being new = 1 or 0. Buy how do a get a kappa statistic with a by statement?

Reeza
Super User
I would structure my data as:

ID Code Old New
1 A 1 1
1 B 0 1


etc then do:

proc freq data=have;
by code;
table old*new / agree ;
run;
Melk
Lapis Lazuli | Level 10

So what I did was concatenate the text to trigger the macro for all the variables in my data:

 


proc sql;
select cat('%mymacro(',name, ',', cats(name, '_new' ),')') into :renstr separated by ' ' from
dictionary.columns where libname = 'WORK' and memname='DATA';
quit;

 

Then I just copied and pasted the result into my SAS code.... 

Reeza
Super User
Or add CALL EXECUTE which would just call the string so you don't have to copy it and run it manually

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 6 replies
  • 600 views
  • 1 like
  • 2 in conversation