BookmarkSubscribeRSS Feed
acordes
Rhodochrosite | Level 12

How to transfer the sql code (working) to its fedsql silbing?

 

proc sql;
		create table sum22 as 
			select a.*, b.fini, put(a.year,4.) as _year 
               from PUBLIC.ALL_MONTHLY_COPY a   join 
					(select sum(fin) as fini, from_brand, year from 
					PUBLIC.ALL_MONTHLY_COPY where  month(mes) <= month(intnx('month', today(), -7, 'end')) and 
					lowcase(producto) <> 'other' AND (VN_VN ='10' or VN_VN = '11') group by from_brand, year 
					) b 
			on a.from_brand=b.from_brand and a.year=b.year;
quit;

But in fedsql it gives an ERROR: Function MONTH(DOUBLE) does not exist so I circumvent to this unefficient code. 

proc cas;
source MPG_toyota;
		create table public.sum22{options replace=true} as 
			select a.*, b.fini, put(a.year,4.) as _year 
               from PUBLIC.ALL_MONTHLY_COPY a   join 
					(select sum(fin) as fini, from_brand, year from 
					PUBLIC.ALL_MONTHLY_COPY where  month(mes) <= month(intnx('month', today(), -7, 'end'))  and 
					lowcase(producto) <> 'other' AND (VN_VN ='10' or VN_VN = '11') group by from_brand, year 
					) b 
			on a.from_brand=b.from_brand and a.year=b.year  ;
endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;
data _null_;
format _fecha_cierre date9.;
_fecha_cierre=intnx('month', today(), -7, 'end');
call symputx("fecha_cierre", _fecha_cierre);
run;

%let tt=%sysfunc(putn(&fecha_cierre., month.));
%put &fecha_cierre. &tt.;

proc cas;
source MPG_toyota;
		create table public.sum22{options replace=true} as 
			select a.*, b.fini, put(a.year,4.) as _year 
               from PUBLIC.ALL_MONTHLY_COPY a   join 
					(select sum(fin) as fini, from_brand, year from 
					PUBLIC.ALL_MONTHLY_COPY where  month(mes) <= &tt. and 
					lowcase(producto) <> 'other' AND (VN_VN ='10' or VN_VN = '11') group by from_brand, year 
					) b 
			on a.from_brand=b.from_brand and a.year=b.year  ;
endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;

 

1 REPLY 1
yabwon
Onyx | Level 15

Could you share some more log?

B.

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 618 views
  • 1 like
  • 2 in conversation