DATA ABC;
INPUT TDATE DATE9. AVG;
CARDS;
18APR2008 150.00
19APR2008 167.00
20APR2008 123.00
21APR2008 145.00
;
RUN
HOW CAN I FIND THE DIFFERENCE BETWEEN AVG OF 18APR2008 ANF
21APR2008??
IF ANY ONE GETS IT PLS TRY TO POST IT.
Answers were Sorted based on User's Feedback
Answer / rajaanku11
The Above can be done in a single data step as
follows.Actually this is suggestable.
data _null_;
set abc;
retain z;
if tdate='18APR2008'D then
z=avg;
if tdate='21APR2008'D then
do;
diff=Z-avg;
put 'the difference=' diff;
stop;
end;
run;
Is This Answer Correct ? | 5 Yes | 1 No |
Answer / nagesh sriram
Hi,
I am think that the difference between the first and last
records value?
data _null_;
set abc end=last;
retain first;
if _n_=1 then first=avg;
if last=1 then do;
diff=first - avg;
put 'The difference is =' diff;
stop;
end;
run;
here _n_=1 is hold the first record in the abc dataset.
Last=1 means is hold the last record in the dataset.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / kumaraswamy maduri
If you want only for the above specified dates then answer
3 works and if it is for first and last observations in the
dataset then answer 4 works.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / rajaanku11
Hi, pls modify slight changes to the above prog.
data _null_ ;
set abc;
if tdate='18APR2008'D then
call symput('x',avg);
if tdate='21APR2008'D then
call symput('y',avg);
run;
%put _user_;
data _null_;
z=&x-&y;
put 'the difference=' z;
run;
Is This Answer Correct ? | 2 Yes | 3 No |
Answer / abhilash
Use symgetfunction to resolve a macro variable with in same
data step while creating macro variable using call symput.
DATA test;
SET ABC;
IF TDATE='18APR2008'D THEN
CALL SYMPUT('A2',AVG);
ELSE IF TDATE='21APR2008'D THEN
CALL SYMPUT('B2',AVG);
diff = symget('a2') - symget('b2');
RUN;
Is This Answer Correct ? | 1 Yes | 2 No |
DATA ABC;
INPUT TDATE DATE9. AVG;
CARDS;
18APR2008 150.00
19APR2008 167.00
20APR2008 123.00
21APR2008 145.00
;
RUN;
data _null_;
set abc;
if tdate='18APR2008'D then
call symput('x',avg);
if tdate='21APR2008'D then
call symput('y',avg);
z=&x-&y;
run;
data _null_;
z=&x-&y;
put 'the difference='z;
run;
Is This Answer Correct ? | 2 Yes | 4 No |
Enlist the syntax rules followed in sas statements.
what is the primary variable in your study?
how to delete the duplicate columns permanently in SQL
Mention sas system options to debug sas macros.
What is proc sql pass through facility?
How would you delete observations with duplicate keys?
Below is the table. Required to be output should be the highest number of each student_id. Example. Student_id Subject Marks 1 Hindi 86 2 Hindi 70 3 English 80 . Calculate sum and average marks for each group of student_id Example. Student_id Subject Marks Total Marks Average 1 English 40 181 60.33333 2 English 67 196 65.33333 3 English 80 160 53.33333 PLEASE PROVIDE THE CODE OF ABOVE PROBLEMS
how does sas handle missing values in procs? : Sas programming
Mention few ways with which a “table lookup’ is done in sas programming.
What's the difference between VAR A1 - A4 and VAR A1 - A4?
How would you code a merge that will keep only the observations that have matches from both sets.
5 Answers Accenture, Bank Of America,
Do you need to compute new variables? If so,should you do this before you execute the report-writing procedure?