Prev: Proc Append
Next: Predicted probabilities in GLIMMIX
From: NordlDJ on 10 Dec 2009 21:29 > -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of > Trish Bous > Sent: Thursday, December 10, 2009 5:55 PM > To: SAS-L(a)LISTSERV.UGA.EDU > Subject: Proc Append > > Hi All, > > I am trying to use proc append to merge values from 2 different variables. > I am looking at 3 ICD-9 diagnoses per patient and I want to know what is the > most frequent diagnoses, regardless if it is first or second. > > I am sure that there is a better way to do this, and I hope someone can help. > Data is like this: > ID PRS1 PRS2 > 1 862 0000 > 2 811 862 > 3 9823 0000 > 4 862 6211 > etc. > > My code looks like this: > > data tmp1 (keep=prs1); > set z.neoplasm; > run; > > data tmp2 (keep=prs2); > set z.neoplasm; > run; > > data tmp2; > set tmp2; > rename prs2=prs1; > run; > > > PROC APPEND BASE=tmp1 DATA=tmp2; > RUN; > > proc freq data=tmp1 noprint; tables prs1 / out=t_gb; run; > > proc sort data=t_gb ; by descending count; run; > > proc print data = t_gb ; run; > > Thanks! You could use a view to accomplish what you want. And, there is no need to sort your results, you can use the order=freq option. You did say you had 3 diagnoses but you only show 2. If you have more diagnoses in z.neoplasm you just add them to the array statement in the view definition. data tmp1(keep=id prs) / view=tmp1; set z.neoplasm; array prs_a[*] prs1 prs2; do _n_= 1 to dim(prs_a); prs = prs_a[_n_]; output; end; run; proc freq data=tmp1 order=freq; tables prs; run; Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204
|
Pages: 1 Prev: Proc Append Next: Predicted probabilities in GLIMMIX |