BookmarkSubscribeRSS Feed
Radwan
Quartz | Level 8

Hello 

please i m a new PHD student i just learned how to use SAS for analyzing my data, but here i could not calculate the delta for my variables. so i need the code for that.

i wanna calculate Total accruals which must be calculated by delta equation.

i need to learn how to calculate it

someone help me.

13 REPLIES 13
Community_Guide
SAS Moderator

Hello @Radwan,


Your question requires more details before experts can help. Can you revise your question to include more information? 

 

Review this checklist:

  • Specify a meaningful subject line for your topic.  Avoid generic subjects like "need help," "SAS query," or "urgent."
  • When appropriate, provide sample data in text or DATA step format.  See this article for one method you can use.
  • If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition. Use the Photos button to include the image in your message.
    use_buttons.png
  • It also helps to include an example (table or picture) of the result that you're trying to achieve.

To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message.  From there you can adjust the title and add more details to the body of the message.  Or, simply reply to this message with any additional information you can supply.

 

edit_post.png

SAS experts are eager to help -- help them by providing as much detail as you can.

 

This prewritten response was triggered for you by fellow SAS Support Communities member @Kurt_Bremser

.
Radwan
Quartz | Level 8

thanks for concerning 

actually my issue is that i do not know how to calculate the delta for my variables, to be honest , i m a novice in SAS program. in meantime I am a PHD student. I m doing my research in earning management. 

i already set my variables and imported the data to SAS, but i do not How to run Delta function unfortunately.

so i need general code of Delta function then i will simulate my analysis.

so why i did not make my inquiry clear.

sorry 

i hope i can find my lost here.

i tried by youtube but no one explains this code except by stata program.

Shmuel
Garnet | Level 18

Assuming you have the variables X and Y in the same dataset.

You can define new variable DELTA by:  

delta= x - y;

Now assume you have two datasets, same format and same variable names (e.g. X),

then:

   

proc sort data=table1; by date id; run;
proc sort data=table2; by date id; run;

data diff;
 merge table1(in=in1 rename=(x=x1))
            table2(in=in2 rename=(x=x2))
  ;
    by date id;
         delta = x1 - x2;
run;

as you see, you need to clarify what is the format of your datasets, what are the variables names,

what do you mean by delta (is it just subtraction or is it more complicated mathematics),

in case of more than one dataset - what variables should be in what formula, etc.

 

In some cases using merge is not enough and it involves summary and/or cartesian calculation

done better by proc SQL.

Radwan
Quartz | Level 8

hello Shmuel.

thanks for replying 

 

i got your solution but my point as follows:

i wanna regress this model ( total accruals = Delta cash -  D_current assets  - D_ current liabilties ) 

Delta means the difference between cash of last year and cash of current year.

so how can i manipulate Delta value by sas?

 

thank you again 

Shmuel
Garnet | Level 18

More clarification is needed:

 

1) Doe's current data and last year data present in the same dataset or are they in two datasets ?

 

2) A SAS variable name is limited by length (32), should start with an alphabetic letter and may include

    letters, numbers, '_'  (blanks are forbidden).

 

3) I'm not expert with regression. Someone else, in the forum, will propose you the preferred method. 

 

4) Please post your datasets names and their variable names.

    Just run PROC CONTENTS on each relevant dataset and post the result:

      

proc contents data=<libname>.<dataset name>; run;

5) What SAS platform do you use? Is it on unix or windows? Is it SAS University Edition, SAS Studio? 

    Is it on MF or PC?

Radwan
Quartz | Level 8

thanks dear Shmuel.

yes the last year data in same dataset. other words i have a year variable which is for 18 years so i need to calculate the delta in same dataset. 

i just attached a pic coz my sas does not support saving in txt intension.

please look at Untitled.png 

Shmuel
Garnet | Level 18

@Radwan, you wrote the next formula:

 total accruals = Delta cash -  D_current assets  - D_ current liabilties 

but your variables are: dcl, inv, leverage, ppe, rec, tca, tcl, total_asset, year, _cash, code.

 

1) Can you write the same formula using the variable names instead the documentary you used ?

 

2) You wrote:

 

Delta means the difference between cash of last year and cash of current year.

  am I correct that you need to meet data from two different observations - one of the current and the other of previous year,

  while the file contains data of 18 years ?  

 

  How would you define CURRENT YEAR ? Are you running the program on December or on January ?

  Or maybe you prefer to supply the two years as two parameters to the program ? (year_1, year_2)

   (that will enable you to compare any period between any two years).

 

 Post your formula adding suffix (1) or (2) to the variables names, to represent data of year1 or of year2 .

 

3) Can you post a sample of your data - 3 observations may be enough - by:

proc print data=<libname>.<dataset name> (obs=3);
run;

  that will clarify your data formats.

 

  Copy the report into {i} window.

 

4) I'll be not available for few next weeks. I hope that your answer will be good enough to help the forum

    and make it available to continue to guide you up to the solution.

 

   I believe that getting a base SAS course (online or in a class) may help you much.

Radwan
Quartz | Level 8

Hi Shmuel 

let me make it a bit clear 

1- my formula by using my variables name as follows:

 total accruals = D_ _cash -  D_TCA  - D_ TCA

 

D_ means Delta.

 2-  As for the delta ( the difference between last and current year), i need to calculate as follows( 2001-2000) (2002-2001) ......(2017-2016). in meantime this result must be as a new variables.

 3- i m gonna attach the three obs as you mentioned 

4- i wish you all the best in your absence.

thanks Untitled.png 

Shmuel
Garnet | Level 18

Just short guide - check next link

 

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_reg_sect001...

 

or google search for more documentation and guides "sas documentation for proc reg"

Reeza
Super User

Yes it does, add the statement below or go change your result settings. Exactly where depends on if you're using SAS Studio or a full installation of SAS. 


ods listing;

You can also paste the HTML directly in, instead of using images. 


@Radwan wrote:

 

i just attached a pic coz my sas does not support saving in txt intension.

please look at Untitled.png 


 

Reeza
Super User

Post sample data showing what you have, exactly, what you want, exactly and the logic. 

If you cannot post real data, make fake data.

 

Vague questions = vague answers.

 

This is if you want any help with coding and how to actually do this with your data. Otherwise the responses will continue to be along the type you've received so far. 

 

In addition, I highly recommend you read this page:

https://stackoverflow.com/help/how-to-ask

https://stackoverflow.com/help/mcve

 

 

 


@Radwan wrote:

hello Shmuel.

thanks for replying 

 

i got your solution but my point as follows:

i wanna regress this model ( total accruals = Delta cash -  D_current assets  - D_ current liabilties ) 

Delta means the difference between cash of last year and cash of current year.

so how can i manipulate Delta value by sas?

 

thank you again 


 

Radwan
Quartz | Level 8

absolutely you are right, but the issue is that i still do not have that experience till i can express my problem well.

 

please i posted the description of my data above 

i hope you can find out the error in my data setting 

 

thanks 

 

Reeza
Super User

Is 'delta function' the difference or something else you're referring to? I'm sure your terminology is clear to you, but please re-read your  question and think how someone who knows absolutely nothing about you or your problem would interpret it. At this point there's no clear idea of what you're trying to do, what you can do or even what you're starting with. Have you already imported your data into SAS? 

 

If so, and you're new to programming I recommend stating with SAS Studio and using the Tasks to do your calculations. There's videos on video.sas.com and free courses for learning, either on Coursera, SAS E-courses or many many tutorials online on various sites. I recommend UCLA in general for their specific tasks. 

 

Good Luck. 

 


@Radwan wrote:

thanks for concerning 

actually my issue is that i do not know how to calculate the delta for my variables, to be honest , i m a novice in SAS program. in meantime I am a PHD student. I m doing my research in earning management. 

i already set my variables and imported the data to SAS, but i do not How to run Delta function unfortunately.

so i need general code of Delta function then i will simulate my analysis.

so why i did not make my inquiry clear.

sorry 

i hope i can find my lost here.

i tried by youtube but no one explains this code except by stata program.


 

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
  • 13 replies
  • 2453 views
  • 1 like
  • 4 in conversation