BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
anweinbe
Quartz | Level 8

I opened a table and created 6 new variables from other variables that are in my dataset. When I run my KEEP command, and specify each of the 6 new variables, only 4 of the 6 are being kept. Whats odd, if I change the order of the variable creation that impacts which of the 6 are being kept too!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Examine this section of code and you will find several missing semicolons:

 


label profitability = "Profitability" ;

tangibility = PPENT/tot_assets;
label tangibility = "Tangibility" ;

/*should XDP be DPC?*/

Dep_to_Assets = XDP/tot_assets;
label Dep_to_Assets = "Depreciation to Assets" ;

Join the club.  We've all done that one time or another.

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Welcome.

 

Please show us the code. Copy and paste the code as text into the window that appears when you click on the "running man" icon.

--
Paige Miller
anweinbe
Quartz | Level 8

If you look toward the bottom I create a series of variables, for some reason it is not keeping the tangibility variable or the debt to assets variable. I get a note

NOTE: Variable tangibility is uninitialized.
NOTE: Variable Dep_to_Assets is uninitialized.

 

 

data temp.compdata; set temp.compdata;
if indfmt="INDL" & datafmt="STD" & popsrc="D" & consol="C";
if fyear > 1990 and fyear < 2015;
if sich <= 4999 and sich >= 4900 then delete;
if sich <= 6999 and sich >= 6000 then delete;


/*Then start building debt and control variables based on the paper - see paper appendix for var defs). You can look
up variable names on the WRDS web site by accessing the FUNDA file and clicking on the variable definitions tab.*/

/*Create four measures of debt" - first need to define debt and assets*/
/*book leverage, market leverage, book LTD, market LTD*/

tot_debt = dlc + dltt;
label tot_debt = "Total_Debt";

tot_assets = at;
label tot_assets = "Total_Assets";

/* here are my book leverage for total and LT*/

book_lev = tot_debt / tot_assets;
label book_lev = "Book_Leverage";

LT_book_lev = dltt / tot_assets;
label lt_book_lev = "LT_Book_Leverage";

/* here are my market calcs, MVA is the denominator instead of total assets*/

mva = (prcc_f * cshpri) + dlc + dltt + pstkl - txditc;
label mva = 'Mkt Value of Assets';

market_lev = tot_debt / mva;
label market_lev = "market_Leverage";

LT_market_lev = dltt / mva;
label lt_market_lev = "LT_Market_Leverage";

/* Now create all the control variables in the paper/*
/* firm size, market 2 book, profitability, tangibility, depreciation / assets*/

firm_size = .;
if sale > 0 then firm_size = log(sale);
label firm_size = 'Firm Size';

market2book = MVA/tot_assets;
label market2book = "M2B Ratio";

profitability = EBITDA/tot_assets;
label profitability = "Profitability"

tangibility = PPENT/tot_assets;
label tangibility = "Tangibility"

/*should XDP be DPC?*/

Dep_to_Assets = XDP/tot_assets;
label Dep_to_Assets = "Depreciation to Assets"

/* why do I need the RD assets? */

rd_assets=.;
if xrd ne . then rd_assets = xrd/firm_size;
label rd_assets = 'R&D/Log Sales';

keep gvkey fyear sich book_lev lt_book_lev market_lev lt_market_lev firm_size market2book profitability tangibility Dep_to_Assets;
run;

Astounding
PROC Star

Examine this section of code and you will find several missing semicolons:

 


label profitability = "Profitability" ;

tangibility = PPENT/tot_assets;
label tangibility = "Tangibility" ;

/*should XDP be DPC?*/

Dep_to_Assets = XDP/tot_assets;
label Dep_to_Assets = "Depreciation to Assets" ;

Join the club.  We've all done that one time or another.

anweinbe
Quartz | Level 8

THANK YOU!!!!

 

I'm a student who was assigned a project in this tool. Guess I have to be SUPER careful on colons! 

ballardw
Super User

@anweinbe wrote:

THANK YOU!!!!

 

I'm a student who was assigned a project in this tool. Guess I have to be SUPER careful on colons! 


The Semicolon is the SAS statement ender. All code up to the semicolon is considered a single statement. Often the missing semicolon will generate errors but depending on the actual statements may not.

 

Unexpected data results are one possible symptom of missing semicolons. But do read the log as often there will be indications there with odd looking notes or just plain errors.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1119 views
  • 1 like
  • 4 in conversation