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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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