BookmarkSubscribeRSS Feed
veebee1
Calcite | Level 5

data _null_;
set ave.emp;
NEWSAL=sal;
put ' ';
put 'CURRENT SALARY FOR ' ename ' IS ' sal;
do lily = 1 to 15;
newsal=newsal+newsal*.20;
put ' AND HIS EXPECTED SALARY FOR THE ' lily ' YEAR IS ' newsal;
end;
run;

 

/*TASK - 1*/

/*hike the sal for all with 20% but only on alternate years till crossing 10 years*/


/*TASK - 2*/

/*hike the sal for dept 10 with 10%, for 20 with 20% and for the rest with 30% for 3 years*/

 

/*TASK - 3*/

/*debug the above code and check the results*/

21 REPLIES 21
Kurt_Bremser
Super User

@veebee1 wrote:

data _null_;
set ave.emp;
NEWSAL=sal;
put ' ';
put 'CURRENT SALARY FOR ' ename ' IS ' sal;
do lily = 1 to 15;
newsal=newsal+newsal*.20;
put ' AND HIS EXPECTED SALARY FOR THE ' lily ' YEAR IS ' newsal;
end;
run;

 

/*TASK - 1*/

/*hike the sal for all with 20% but only on alternate years till crossing 10 years*/


/*TASK - 2*/

/*hike the sal for dept 10 with 10%, for 20 with 20% and for the rest with 30% for 3 years*/

 

/*TASK - 3*/

/*debug the above code and check the results*/


And what is your question?

veebee1
Calcite | Level 5

There are 3 tasks listed to create from the data set.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, but these are Your tasks for some sort of course.  What is your question bearing in mind we are not here to do your course for you.

veebee1
Calcite | Level 5

how do YOU know this is for some kind of course, did I ask YOU to do it for me?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, you posted a question on the forum with the idea to get a response.

veebee1
Calcite | Level 5

"with the idea to get a response" - only to get an idea to complete the task because I am either stuck or not sure of my answer. If you have no contribution or can't solve it, please do not respond. Thank You.

Astounding
PROC Star

Not too many posters will just do your homework for you.  Here is a tip to get you started.

 

do lily = 1 to 15;
newsal=newsal+newsal*.20;
put ' AND HIS EXPECTED SALARY FOR THE ' lily ' YEAR IS ' newsal;
end;

 

Since you are only expected to go through 10 years, and only expected to report every other year, a couple of changes would be in order.  Depending on whether question 1 wants you to report years 2, 4, 6, 8, 10 (as opposed to years 1, 3, 5, 7, 9):

 

do lily = 2 to 10 by 2;
newsal=newsal * 1.2 * 1.2;
put ' AND HIS EXPECTED SALARY FOR THE ' lily ' YEAR IS ' newsal;
end;

veebee1
Calcite | Level 5

can you help me with the procedure to debug, or it there a code to debug?

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

data have / debug;

… stuff you want to do...

run;

veebee1
Calcite | Level 5

Thank you.

Kurt_Bremser
Super User

@veebee1 wrote:

can you help me with the procedure to debug, or it there a code to debug?


Run it, read the log, and inspect the resulting dataset (if the code doesn't conk out with ERROR(s)).

If you want us to test your code, we need the data you run it on. Post example data (ave.emp) in a data step with datalines, so it is easy for us to recreate it.

veebee1
Calcite | Level 5


data _null_;
set ave.emp;
NEWSAL=sal;
put ' ';
put 'CURRENT SALARY FOR ' ename ' IS ' sal;
do lily = 2 to 10 by 2;
newsal=newsal * 1.2 * 1.2;
put ' AND HIS EXPECTED SALARY FOR THE ' lily ' YEAR IS ' newsal;
end;
run;

 

 

data _null_;
set ave.emp;
NEWSAL=sal;
put ' ';
put 'CURRENT SALARY FOR ' dept=10 ' IS ' sal;
newsal=newsal+newsal*.10;
put 'CURRENT SALARY FOR ' dept=20 ' IS ' sal;
newsal=newsal+newsal*.20;
put 'CURRENT SALARY FOR ' dept=30 ' IS ' sal;
newsal=newsal+newsal*.30;
do lily = 1 to 3;
put ' AND HIS EXPECTED SALARY FOR THE ' lily ' YEAR IS ' newsal;
end;
run;

Kurt_Bremser
Super User

@veebee1 wrote:


data _null_;
set ave.emp;
NEWSAL=sal;
put ' ';
put 'CURRENT SALARY FOR ' ename ' IS ' sal;
do lily = 2 to 10 by 2;
newsal=newsal * 1.2 * 1.2;
put ' AND HIS EXPECTED SALARY FOR THE ' lily ' YEAR IS ' newsal;
end;
run;

 

 

data _null_;
set ave.emp;
NEWSAL=sal;
put ' ';
put 'CURRENT SALARY FOR ' dept=10 ' IS ' sal;
newsal=newsal+newsal*.10;
put 'CURRENT SALARY FOR ' dept=20 ' IS ' sal;
newsal=newsal+newsal*.20;
put 'CURRENT SALARY FOR ' dept=30 ' IS ' sal;
newsal=newsal+newsal*.30;
do lily = 1 to 3;
put ' AND HIS EXPECTED SALARY FOR THE ' lily ' YEAR IS ' newsal;
end;
run;


Nice. You're using ave.emp. Where's the example data for that?

Without knowing what is in that dataset, there's no way to verify your code (reliably).

veebee1
Calcite | Level 5
libname _all_ clear;

libname ave 'c:\sample';

data e;
set ave.emp;
NEWSAL=sal;
do lily = 1 to 5;
newsal=newsal+newsal*.20;
end;
run;

data _null_;
set ave.emp;
NEWSAL=sal;
put ' ';
put 'CURRENT SALARY FOR ' ename ' IS ' sal;
do lily = 1 to 5;
newsal=newsal+newsal*.20;
put ' AND HIS EXPECTED SALARY FOR THE ' lily ' YEAR IS ' newsal;
end;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 21 replies
  • 5079 views
  • 1 like
  • 5 in conversation