jdemaio Tracker
https://communities.sas.com/kntur85557/tracker
jdemaio TrackerSat, 13 Apr 2024 01:09:08 GMT2024-04-13T01:09:08ZRe: random access to variables in observations
https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433224#M2189
<P>Works perfectly.</P><P> </P><P>Thanks!</P><P> </P><P>Joe</P>Thu, 01 Feb 2018 18:45:09 GMThttps://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433224#M2189jdemaio2018-02-01T18:45:09Zrandom access to variables in observations
https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433131#M2185
<P>Hello,</P><P> </P><P>I've playing around with Proc OptGraph recently. I have a data set consisting of district representatives in CA and the committees that they serve on. Here are the first 10 observations sorted by committee assignment.</P><P> </P><P>Obs District Name Committee Assignment<BR />1 16th Costa, Jim Agriculture<BR />2 10th Denham, Jeff Agriculture<BR />3 1st LaMalfa, Doug Agriculture<BR />4 20th Panetta, Jimmy Agriculture<BR />5 31st Aguilar, Pete Appropriations<BR />6 42nd Calvert, Ken Appropriations<BR />7 13th Lee, Barbara Appropriations<BR />8 40th Roybal-Allard, Lucille Appropriations<BR />9 21st Valadao, David Appropriations<BR />10 24th Carbajal, Salud Armed Services</P><P> </P><P>I've analyzed the bipartite graph whose nodes come from the name and committee assignment variables. Edges appear from name to committee assignment if that member serves on said committee. </P><P> </P><P>I now want to create a new graph whose nodes are the names and an edge exists between two names if they sit on a common committee. For example, Agriculture will generate 4 choose 2= 6 edges in the new graph, one of which is Costa-Denham. So, I want to create a new data set from my current data set with two variables:rep1 and rep2. I think that I want to use nested for loops to check committee assignment for every pair of observations and if they match then output the observation names into my new data set as rep1 and rep2. My first 7 observations in the new data set would be:</P><P> </P><P>Obs rep1 rep2</P><P>1 Costa Denham</P><P>2 Costa LaMalfa</P><P>3 Costa Panetta</P><P>4 Denham LaMalfa</P><P>5 Denham Panetta</P><P>6. LaMalfa Panetta</P><P>7 Aguilar Calvert</P><P> </P><P>What I don't know how to do, if possible in SAS, is look at the specific entries in observations to compare and then write to a new data set. Suggestions?</P><P> </P><P>Thanks,</P><P> </P><P>Joe</P>Thu, 01 Feb 2018 15:19:41 GMThttps://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433131#M2185jdemaio2018-02-01T15:19:41Z