Question
Convert the following code from SAS to R /*import bh*/ proc contents data=pace; run; /*select relavant variables only*/ data pace1 (rename=(_0sexcludedataquality=pbexclude)); set pace; keep vasccid
Convert the following code from SAS to R
/*import bh*/ proc contents data=pace; run; /*select relavant variables only*/ data pace1 (rename=(_0sexcludedataquality=pbexclude)); set pace; keep vasccid _0sexcludedataquality wb10sp01-wb10sp15; run; /*exclude pts with dq issues*/ data pace2; set pace1; if pbexclude=1 then delete; run; proc print data=pace2; run; proc sort data=pace2; by vasccid; run; /*transform data into a long format*/ proc transpose data=pace2 out=longpace; by vasccid; var wb10sp01-wb10sp15; run; proc print data=longpace; run; /*create timepoint variable from wb10sp__*/ data longpace (rename=(COL1=WBCBF)); set longpace; TP=input(substr(_name_,7),2.); drop _name_; retain vasccid TP _label_ WBCBF; run; /*rank wbcbf from high to low*/ proc rank data=longpace out=outlong ties=low descending; by vasccid; var WBCBF; ranks CBF_rank; run; proc print data=outlong; run; /*check if there are any ties*/ proc freq data=outlong; tables CBF_rank; run; *no ties; /*label largest value=max smallest value=min*/ data minmax; set outlong; by vasccid; if CBF_rank=1 then minmax='max'; else if CBF_rank=15 then minmax='min'; run; proc print data=minmax; run; /*keep only mininum and maximum values*/ data minmaxx; set minmax; if minmax eq 'min' or minmax eq 'max'; run; /*export as a .csv file*/ /*Dir: C:\Users\jungy\VaSC Lab Dropbox\Jung Yun Jang\CVR_analysis_spreadsheets*/ /* import bh */ proc contents data=bh; run; data bh1 (rename=(bhexcludedataquality=bhexclude)); set bh; keep vasccid bhexcludedataquality wbbhp01-wbbhp15; run; data bh2; set bh1; if bhexclude=1 then delete; run; proc sort data=bh2; by vasccid; run; proc transpose data=bh2 out=longbh; by vasccid; var wbbhp01-wbbhp15; run; proc print data=longbh; run; data longbh (rename=(COL1=WBCBF)); set longbh; TP=input(substr(_name_,6),2.); drop _name_; retain vasccid TP _label_ WBCBF; run; proc print data=longbh; run; proc rank data=longbh out=outlongbh ties=low descending; by vasccid; var WBCBF; ranks CBF_rank; run; proc print data=outlongbh; run; proc freq data=outlongbh; tables CBF_rank; run; *no ties; data minmax1; set outlongbh; by vasccid; if CBF_rank=1 then minmax='max'; else if CBF_rank=15 then minmax='min'; run; proc print data=minmax1; run; data minmaxx1; set minmax1; if minmax eq 'min' or minmax eq 'max'; run; /*export as a csv file*/
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started