BookmarkSubscribeRSS Feed
BaharH
Calcite | Level 5

Hi.

I want to extract the most recent date from my data in each group. It's easy when I have a table ready. But when I want to extract from my metadata it doesn't work. especially with a where clause. My data is tooooooooo big. So I can't extract everything and then group it. Please help me. I used max(qtm.kalenderday) for the last data.

PROC SQL;
	CONNECT TO ODBC AS mycon (datasrc=DMA_P);
	CREATE TABLE work.Company AS

	select *
		FROM CONNECTION TO mycon 
			(SELECT	
				qtm. Day,
				qtm. NR,
				qtm.name,
                qtm.kalenderday,
                qvm.WGnumber
				
			FROM dmameting_tr qvm,
				dm_ameting qtm,
				dmameting_wh WiK
		
			where
				qtm.qtmunitnr = WiK.meetunitnr
				and qtm.unitnr = qvm.unitnr 
				and qtm.meettijdstip_dt = qvm.meettijdstip_dt
				and max(qtm.kalenderday)
                group by qvm.WGnumber
			);
run;

DISCONNECT FROM mycon;
QUIT;
1 REPLY 1
LinusH
Tourmaline | Level 20

Since you are using SQL pass through, this is not a SAS question really.

You should redirect this optimization inquire to forum specific for your source database.

Data never sleeps

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 521 views
  • 0 likes
  • 2 in conversation