BookmarkSubscribeRSS Feed
lakshya
Calcite | Level 5

need help to convert  below sql query into proc sql or data set query of sas 


Select x.*
from yyy x
inner join
(
select abc, ad, min(date) as Minad
from dbo.xx
where xx in ('xx' ,'xx' ,'xx' ) AND Activity_Date >= 'mm/dd/yyyy'
group by case_ID, Activity
)
as b on a.abc = b.abc and a.ad=b.Minad
where (a.ad)>= 'mm/dd/yyyy' and a.abc in ('xx' ,'xx' ,'xx' ) AND B.xx  IS NOT NULL
group by a.abc,a.xx,b.xx

 

8 REPLIES 8
lakshya
Calcite | Level 5

need help to convert  below sql query into proc sql or data set query of sas 


Select x.*
from yyy x
inner join
(
select abc, ad, min(date) as Minad
from dbo.xx
where xx in ('xx' ,'xx' ,'xx' ) AND Activity_Date >= 'mm/dd/yyyy'
group by case_ID, Activity
)
as b on a.abc = b.abc and a.ad=b.Minad
where (a.ad)>= 'mm/dd/yyyy' and a.abc in ('xx' ,'xx' ,'xx' ) AND B.xx  IS NOT NULL
group by a.abc,a.xx,b.xx

PeterClemmensen
Tourmaline | Level 20

As I read it, there is nothing in your code not supported by PROC SQL in SAS, so simply wrap it inside a PROC SQL call.

lakshya
Calcite | Level 5
But it's not working so syntax error
It gives syntax error
PeterClemmensen
Tourmaline | Level 20

What error appears in the log?

Reeza
Super User

 

Post your FULL LOG.

art297
Opal | Level 21

If activity_date and ad are SAS dates, and 'mm/dd/yy' are actually numbers, you should use the form:

AND Activity_Date >= 'ddmonyyyy'd

Art, CEO, AnalystFinder.com

 

kiranv_
Rhodochrosite | Level 12

I do not completly understand the query. But most of it should work in Proc SQL too. Except few changes where you mention date columns and at is not null.

 

Activity_Date >= 'mm/dd/yyyy'

to

Activity_Date >= 'ddmmmyyyy'd  example '21jul2017'd

 

is not null

to

is not missing

 

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 8 replies
  • 1774 views
  • 0 likes
  • 5 in conversation