BookmarkSubscribeRSS Feed
Gieorgie
Quartz | Level 8

I have a code that checks for me if there is any record for the last day of the month. However, I would need it to show me only one item, i.e. one record, not 148,000 dates as in the photo below

proc sql;
create table BH_D_ZAB_X_ALOK as 
select DATA_DANYCH as DATA_DANYCH from cmz.BH_D_ZAB_X_ALOK_&thismonth
             where DATA_DANYCH eq intnx('month',DATA_DANYCH,0,'e')
			 group by DATA_DANYCH

			  ;
quit;

Gieorgie_0-1649065415772.png

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Easily handled in a DATA step

 

data want;
    set bh_d_zab_x_alok;
    by data_danych;
    if first.data_danych;
run;
--
Paige Miller
Ksharp
Super User
proc sql;
create table BH_D_ZAB_X_ALOK as
select distinct DATA_DANYCH as DATA_DANYCH from cmz.BH_D_ZAB_X_ALOK_&thismonth
where DATA_DANYCH eq intnx('month',DATA_DANYCH,0,'e')
group by DATA_DANYCH

;
quit;
Patrick
Opal | Level 21
proc sql;
  create table BH_D_ZAB_X_ALOK as
    select max(DATA_DANYCH) as DATA_DANYCH 
    from cmz.BH_D_ZAB_X_ALOK_&thismonth
    where DATA_DANYCH eq intnx('month',DATA_DANYCH,0,'e')
  ;
quit;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 297 views
  • 0 likes
  • 4 in conversation