BookmarkSubscribeRSS Feed
reddy19
Calcite | Level 5
Hi,

33822730 12/27/2007 xyz Approval
33822730 2/4/2009 xyz Referral

I have to switch the values of APPROVAL and REFERRAL depending on date.For each id the first date value should be approval and second date value should be Refferal,only if approval and refferal are present for perticular id.

How can acheive this using EG.

reddy
3 REPLIES 3
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Reddy19,

This is a solution:
[pre]
data i;
input id date ANYDTDTE10. field $ Status $ 25-32;
format date date7.;
datalines;
33822730 12/27/2007 xyz Approval
33822730 2/3/2009 xyz
33822730 2/4/2009 xyz Referral
33822730 2/5/2009 xyz
run;
proc sort data=i;
by id date;
run;
data r;
set i;
if FIRST.id and UPCASE(Status) in ("APPROVAL" "REFERRAL") then s="Referral";
else if UPCASE(Status) in ("APPROVAL" "REFERRAL") then s="Approval";
by id;
run;
[/pre]
Sincerely,
SPR
reddy19
Calcite | Level 5
Through programming i will be able to do it.

But using EG(point and click interface),i'm not able to figure it out...can you please suggest me how i could do this using EG.

Thanks a lot,
reddy
Patrick
Opal | Level 21
Hi

The query wizard in EG generates SQL code.
Writing logic in SQL where you need to do things on a "first" and "second" row is often tricky. Procedural languages like Base SAS are much better suited for this.

So even with the best (SQL) query wizard it would be rather hard to set up this query.

Why not use the possibilities EG gives you - which in this case would be the programming window.

HTH
Patrick

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 944 views
  • 0 likes
  • 3 in conversation