Sas- proc sql တွင် order by ကိုအသုံးပြုနည်း
တစ်ခု သို့မဟုတ် တစ်ခုထက်ပိုသော variable များ၏တန်ဖိုးများအပေါ်အခြေခံ၍ query တစ်ခု၏ရလဒ်များကိုစီရန် SAS ရှိ PROC SQL တွင် ORDER BY ကြေညာချက်ကို သင်အသုံးပြုနိုင်သည်။
ဤသည်မှာ ORDER BY ထုတ်ပြန်ချက်ကို လက်တွေ့တွင် အသုံးပြုရန် ဘုံသုံးနည်းများဖြစ်သည်-
နည်းလမ်း 1- တိုးလာသောကိန်းရှင်ဖြင့် မှာယူပါ။
/*display results in ascending order by value in team column*/
proc sql ;
select *
from my_data
order by team ;
quit ;
နည်းလမ်း ၂
/*display results in descending order by value in team column*/
proc sql ;
select *
from my_data
order by team desc ;
quit ;
နည်းလမ်း 3- ကိန်းရှင်များစွာဖြင့် အစဉ်လိုက်
/*display results in ascending order by team, then descending order by points*/
proc sql ;
select *
from my_data
order by team, points desc ;
quit ;
အောက်ဖော်ပြပါနမူနာများသည် ဘတ်စကက်ဘောကစားသမားများအကြောင်း အချက်အလက်များစွာပါရှိသော SAS ရှိ အောက်ပါဒေတာအတွဲဖြင့် နည်းလမ်းတစ်ခုစီကို လက်တွေ့အသုံးပြုနည်းကို ပြသသည်-
/*create dataset*/
data my_data;
input team $position $points assists;
datalines ;
A Guard 14 4
B Guard 22 6
B Guard 24 9
A Forward 13 8
C Forward 13 9
A Guard 10 5
B Guard 24 4
C Guard 22 6
D Forward 34 2
D Forward 15 5
B Forward 23 5
B Guard 10 4
;
run ;
/*view dataset*/
proc print data =my_data;
ဥပမာ 1- တိုးလာသောကိန်းရှင်ဖြင့် မှာယူပါ။
အောက်ပါကုဒ်သည် အဖွဲ့ ကော်လံတန်ဖိုးများကို အခြေခံ၍ ဒေတာအတွဲအတွင်း အတန်းလိုက်တစ်ခုစီကို မည်သို့ပြန်ဆိုရမည်ကို ပြသသည်-
/*display results in ascending order by value in team column*/
proc sql ;
select *
from my_data
order by team;
quit ;
ရလဒ်များကို အဖွဲ့ ကော်လံရှိ တန်ဖိုးများဖြင့် ကြီးလိုက်ကြီးလိုက် ဖော်ပြသည်ကို သတိပြုပါ။
ဥပမာ 2- လျှော့ချထားသောကိန်းရှင်ဖြင့် မှာယူပါ။
အောက်ပါကုဒ်သည် အဖွဲ့ ကော်လံတန်ဖိုးများကို အခြေခံ၍ ဒေတာအတွဲရှိ အတန်းတစ်ခုစီကို ကြီးစဉ်ငယ်လိုက် မည်သို့ပြန်ဆိုရမည်ကို ပြသသည်-
/*display results in descending order by value in team column*/
proc sql ;
select *
from my_data
order by team desc ;
quit ;
Team ကော်လံရှိ တန်ဖိုးများကို အခြေခံ၍ ရလဒ်များကို ကြီးစဉ်ငယ်လိုက် ဖော်ပြသည်ကို သတိပြုပါ။
ဥပမာ 3- ကိန်းရှင်များစွာဖြင့် အစဉ်လိုက်
အောက်ပါကုဒ်သည် ဒေတာအတွဲရှိ အတန်းတစ်ခုစီကို အဖွဲ့အလိုက် ကြီးလိုက်ကြီးလိုက်၊ ထို့နောက် အမှတ်များ အလိုက် ကြီးစဉ်ငယ်လိုက် မည်သို့ပြန်ရမည်ကို ပြသသည်-
/*display results in ascending order by team, then descending order by points*/
proc sql ;
select *
from my_data
order by team, points desc ;
quit ;
ရလဒ်များကို အသင်းအလိုက် ကြီး လိုက်ကြီးလိုက် ပထမဦးဆုံး ပြသသည်ကို သတိပြုပါ၊ ထို့နောက် အမှတ်အလိုက် ကြီးစဉ်ငယ်လိုက် ဖော်ပြသည်ကို သတိပြုပါ။
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် SAS တွင် အခြားဘုံအလုပ်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
SAS- PROC SQL တွင် UNION ကိုအသုံးပြုနည်း
SAS- PROC SQL တွင် EXCEPT ကို မည်သို့အသုံးပြုရမည်နည်း။
SAS- PROC SQL တွင် IN အော်ပရေတာအား အသုံးပြုနည်း
SAS- PROC SQL တွင် WHERE အော်ပရေတာအား မည်သို့အသုံးပြုရမည်နည်း။