Prev: ANOVA-based Intraclass correlation coefficient
Next: How do I disable sort when creating a new dataset from another?
From: SD on 11 Jun 2010 04:10 Hello All, Would like to create a dataset. would appreciate your help. Dataset - Have year_month Region Country Company Marks 200202 AP CN Agile 45 200202 AP TW RBS 45 200204 AP IN BCU 55 200210 AP KR OP 56 200204 EMEA DE Agile 56 200210 EMEA FR BCU 45 Dataset - want year_month Region Country Company Marks 200202 AP CN Agile 45 200202 AP TW RBS 45 200202 AP IN BCU 55 200202 AP KR OP 56 200204 AP CN Agile 45 200204 AP TW RBS 45 200204 AP IN BCU 55 200204 AP KR OP 56 200210 AP CN Agile 45 200210 AP TW RBS 45 200210 AP IN BCU 55 200210 AP KR OP 56 200210 AP KR OP 56 200204 EMEA DE Agile 56 200204 EMEA FR BCU 45 200210 EMEA DE Agile 56 200210 EMEA FR BCU 45 thanks SD
From: Richard A. DeVenezia on 11 Jun 2010 11:15
On Jun 11, 4:10 am, SD <saurabhk...(a)gmail.com> wrote: > Hello All, > > Would like to create a dataset. would appreciate your help. > > Dataset - Have > > year_month Region Country Company Marks > 200202 AP CN Agile 45 > 200202 AP TW RBS 45 > 200204 AP IN BCU 55 > 200210 AP KR OP 56 > 200204 EMEA DE Agile 56 > 200210 EMEA FR BCU 45 > > Dataset - want > year_month Region Country Company Marks > 200202 AP CN Agile 45 > 200202 AP TW RBS 45 > 200202 AP IN BCU 55 > 200202 AP KR OP 56 > 200204 AP CN Agile 45 > 200204 AP TW RBS 45 > 200204 AP IN BCU 55 > 200204 AP KR OP 56 > 200210 AP CN Agile 45 > 200210 AP TW RBS 45 > 200210 AP IN BCU 55 > 200210 AP KR OP 56 > 200210 AP KR OP 56 > 200204 EMEA DE Agile 56 > 200204 EMEA FR BCU 45 > 200210 EMEA DE Agile 56 > 200210 EMEA FR BCU 45 > > thanks > SD Saurab: I am presuming the two wanted lines > 200210 AP KR OP 56 > 200210 AP KR OP 56 are an unintentional duplicate. If so, the following self join will produce 'want' ---------- proc sql; create table want as select A.YM , A.Region , B.Country , B.Company , B.Marks , B.id from (select distinct YM, region from have) as A , have as B where A.region = B.region order by Region, YM, id ; quit; ---------- Richard A. DeVenezia http://www.devenezia.com |