DATA STEP CODES TO SQL

Reply
New Contributor
Posts: 4

DATA STEP CODES TO SQL

i have different data steps code, i need help to convert them to sql. 

 

Could any one please help me with belwo data step codes to sql?

 


data w6.data3; set W6.data3;
data data4; set data3;
if SIC ge 6300 and SIC le 6350 then delete; /***Delete financial firms***/
if SIC ge 4900 and SIC le 4939 then delete; /***Delete utilities***/
if TACC_t eq . then delete;
if TA_t in (0, .) then delete;/***used to calculate ROA***/
if TA_tm1 in (0, .) then delete;/***used to calculate ROA***/
if Sales_t eq . then delete;
if Sales_tm1 eq . then delete;
if AR_ch_t eq . then delete;
if PPE_t eq . then delete;
if NI_t eq . then delete;
if NI_tm1 eq . then delete;
if AR_ch_t eq . then delete;
if MVE_tm1 eq 0 then delete; /*mused for extreme samples***/
Sales_ch_t = (Sales_t-Sales_tm1)/TA_tm1;
Sales_t=Sales_t/TA_tm1;
AR_ch_t=-AR_ch_t/TA_tm1;/***Note that accounts receivable change is (increase) decrease*/
Sales_rec_ch_t=Sales_ch_t-AR_ch_t;
if sales_rec_ch_t eq . then delete;
TACC_t=TACC_t/TA_tm1;
Int=1/TA_tm1;
EBEX_t=EBEX_t/TA_tm1;
CFO_t=CFO_t/TA_tm1;
PPE_t=PPE_t/TA_tm1;
ROA_t=(NI_t/TA_t);/***Current year net income over beginning total assets * */
ROA_tml=(NI_tm1/TA_tm1);/***Last year ROA***/
run;


proc sort data=data4; by SIC t;
data data4; set data4;
proc univariate noprint; var TACC_t;
output out=N n=N;
by SIC t; * t=yeara;
run;

 

data data5; merge data4 N; /***4-digit SIC code Eliminate SIC t combination with less than 10 obs*/
by SIC t; if N < 10 then delete;
run;


data data5; set data5;
proc reg noprint;
model TACC_t = Int Sales_rec_ch_t PPE_t ROA_t;
output out=pred11 p=ETAC1_t; /***r=DA0C1***/
model TACC_t = Int Sales_rec_ch_t PPE_t ROA_tm1;
output out=pred21 p=ETAC2_t /***r=DACC2***/;
by SIC t;
run;


data pred1; set pred1;
DACC1=TACC_t-ETAC1_t;
proc sort; by cusip t;
data pred2; set pred2;
DACC2=TACC_t-ETAC2_t;
proc sort; by cusip t;
run;

 

data data6; merge pred1 pred2;
by cusip t;
class=1;
run;

______________________________________________
data study control; set data6;
if Class eq 1 then output study;
if Class eq 1 then output control;
run;

Respected Advisor
Posts: 4,137

Re: DATA STEP CODES TO SQL

Please don't post the same question in multiple forums. This fragments the discussion an is not helpful.

 

Here the link to where you've got already answers:

https://communities.sas.com/t5/Base-SAS-Programming/DATA-STEPS-TO-SQL/m-p/234781#U234781 

 

Ask a Question
Discussion stats
  • 1 reply
  • 281 views
  • 0 likes
  • 2 in conversation