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*/
@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?
There are 3 tasks listed to create from the data set.
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.
how do YOU know this is for some kind of course, did I ask YOU to do it for me?
Yes, you posted a question on the forum with the idea to get a response.
"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.
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;
can you help me with the procedure to debug, or it there a code to debug?
data have / debug;
… stuff you want to do...
run;
Thank you.
@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.
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;
@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).
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;
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.