01-22-2025
Aexor
Lapis Lazuli | Level 10
Member since
05-05-2020
- 187 Posts
- 149 Likes Given
- 0 Solutions
- 4 Likes Received
-
Latest posts by Aexor
Subject Views Posted 624 01-21-2025 11:27 PM 678 01-21-2025 04:12 PM 1275 12-06-2024 06:30 AM 1295 12-06-2024 06:09 AM 1141 12-06-2024 03:26 AM 1141 12-06-2024 03:25 AM 1141 12-06-2024 03:23 AM 1301 12-05-2024 05:21 PM 839 12-04-2024 06:37 AM 2069 03-09-2024 10:12 AM -
Activity Feed for Aexor
- Posted Re: ERROR: A name token was expected on SAS Viya. 01-21-2025 11:27 PM
- Posted ERROR: A name token was expected on SAS Viya. 01-21-2025 04:12 PM
- Posted Re: Need to store a code in macro variable on SAS Programming. 12-06-2024 06:30 AM
- Posted Need to store a code in macro variable on SAS Programming. 12-06-2024 06:09 AM
- Posted Re: Need to add semicolon in values getting printed on SAS Programming. 12-06-2024 03:26 AM
- Posted Re: Need to add semicolon in values getting printed on SAS Programming. 12-06-2024 03:25 AM
- Liked Re: Need to add semicolon in values getting printed for Tom. 12-06-2024 03:24 AM
- Posted Re: Need to add semicolon in values getting printed on SAS Programming. 12-06-2024 03:23 AM
- Liked Re: Need to add semicolon in values getting printed for Ksharp. 12-06-2024 03:23 AM
- Liked Re: Need to add semicolon in values getting printed for ballardw. 12-06-2024 03:22 AM
- Liked Re: Need to add semicolon in values getting printed for data_null__. 12-06-2024 03:21 AM
- Liked Re: Need to add semicolon in values getting printed for data_null__. 12-06-2024 03:21 AM
- Posted Need to add semicolon in values getting printed on SAS Programming. 12-05-2024 05:21 PM
- Posted macro variable in title statement is not getting resolved correctly on SAS Programming. 12-04-2024 06:37 AM
- Posted Re: Getting duplicate value because of do loop on SAS Programming. 03-09-2024 10:12 AM
- Posted Re: Getting duplicate value because of do loop on SAS Programming. 03-08-2024 06:44 PM
- Posted Getting duplicate value because of do loop on SAS Programming. 03-08-2024 11:44 AM
- Liked Re: do loop is not working as expected for ballardw. 03-01-2024 05:42 AM
- Posted Re: do loop is not working as expected on SAS Programming. 03-01-2024 03:55 AM
- Posted do loop is not working as expected on SAS Programming. 03-01-2024 02:35 AM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 1 1 1 -
My Liked Posts
Subject Likes Posted 1 03-03-2023 09:24 AM 2 08-09-2021 02:35 AM 1 07-29-2021 07:26 AM
01-21-2025
11:27 PM
Thanks for checking. Here is the MPRINT MPRINT(__CODE): proc cas; MPRINT(__CODE): session CASAUTO; MPRINT(__CODE): loadactionset "timeData"; NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks. NOTE: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended. MPRINT(__CODE): action runTimeCode / table={ caslib="CASUSER(swkuma)", name="PRICEDATA" } objOut={ { table={ caslib="CASUSER", name="outStatTemp" , replace="true" }, objRef='outStat' } } seasonality=12 timeId={name='date' , FORMAT="_DATA_"} interval="Month" nlFormat=true series={'sale'} require={{pkg='TSM'}} code=' declare object myModel(TSM); declare object mySpec(ARIMASpec); rc = mySpec.Open(); array ma[2]/nosymbols; ma[1] = 1; ma[2] = 2; rc = mySpec.AddMAPoly(ma); rc = mySpec.SetOption("noint",1); rc = mySpec.SetOption("method","CLS"); rc = mySpec.close(); rc = myModel.Initialize(mySpec); rc = myModel.SetY(sale); rc = myModel.SetOption('lead', 12); rc = myModel.SetOption("alpha",0.05); rc = myModel.Run(); declare object outStat(TSMSTAT); rc = outStat.Collect(myModel); '; ERROR: A name token was expected ERROR: action runTimeCode / table = { caslib = 'CASUSER(swkuma)' , n ERROR: ame = 'PRICEDATA' } objOut = { { table = { caslib = 'CASUSER' ERROR: , name = 'outStatTemp' , replace = 'true' } , objRef = 'outS ERROR: tat' } } seasonality = 12 timeId = { name = 'date' , FORMAT = ERROR: '_DATA_' } interval = 'Month' nlFormat = TRUE series = { 'sa ERROR: le' } require = { { pkg = 'TSM' } } code = ' decla ERROR: re object myModel(TSM); declare object mySpec(ARIM ERROR: ASpec); rc = mySpec.Open(); array ma[2] ERROR: /nosymbols; ma[1] = 1; ma[2] = ERROR: 2; rc = mySpec.AddMAPoly(ma); rc = mySp ERROR: ec.SetOption("noint",1); rc = mySpec.SetOption("me ERROR: thod","CLS"); rc = mySpec.close(); ERROR: rc = myModel.Initialize(mySpec); ERROR: rc = myModel.SetY(sale); rc = myModel.SetOption ERROR: (' lead ', 12); rc = myModel.SetOption("alpha",0.0 ERROR: 5); rc = myModel.Run(); dec ERROR: lare object outStat(TSMSTAT); rc = outStat.Collect ERROR: (myModel); ' ; ERROR: ^ NOTE: The submitted statements have been canceled. MPRINT(__CODE): run; MPRINT(__CODE): ; NOTE: PROCEDURE CAS used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
... View more
01-21-2025
04:12 PM
I have this macro
%macro run_cas_ma; libname _tmpcas_ cas caslib="CASUSER";
proc cas; /* Ensure that the session is set correctly */ session %sysfunc(getlsessref(&dataset_lib)); /* Load the necessary action set */ loadactionset %sysfunc(quote(timeData)); action runTimeCode / table={ caslib=%sysfunc(quote(%sysfunc(getlcaslib(&dataset_lib))))%str(,) name=%sysfunc(quote(&dataset_name)) } /* Table definition comes first */ objOut={ { table={ caslib=%sysfunc(quote(%sysfunc(getlcaslib(_tmpcas_))))%str(,) name=%qsysfunc(quote(outStatTemp)) %str(,) replace=%sysfunc(quote(true)) }%str(,) objRef=%str('outStat') } }
/* Conditionally add forecast output if plotForecastViya is set to 1 */ %if &plotForecastViya = 1 %then %do; %str(,) { table={ caslib=%sysfunc(quote(%sysfunc(getlcaslib(_tmpcas_))))%str(,) name=%sysfunc(quote(outFcastTemp)) %str(,) replace=%sysfunc(quote(true)) }%str(,) objRef=%str('outFcast') } %end;
seasonality=12 timeId={name=%str('date') %str(,) FORMAT=%sysfunc(quote(_DATA_))} interval="Month" nlFormat=true series={'sale'} require={{pkg='TSM'}} code=%str(%') declare object myModel(TSM); declare object mySpec(ARIMASpec); rc = mySpec.Open(); /* Loop to assign values to ma[&i.] */ %do i=1 %to &map.; ma[&i.] = &i.; %end; rc = mySpec.AddMAPoly(ma); rc = mySpec.SetOption("noint",1); rc = mySpec.SetOption("method","CLS"); rc = mySpec.close(); /* Initialize the model */ rc = myModel.Initialize(mySpec); rc = myModel.SetY(&dependVariable); rc = myModel.SetOption('lead', &forecastPeriods); rc = myModel.SetOption("alpha",0.05); rc = myModel.Run(); /* Collect forecast if plotForecastViya is set to 1 */ %if &plotForecastViya = 1 %then %do; declare object outFcast(TSMFor); rc = outFcast.Collect(myModel); %end; declare object outStat(TSMSTAT); rc = outStat.Collect(myModel); %str(%'); run; %mend run_cas_ma;
%run_cas_ma
This i giving me error
MPRINT(__CODE): action runTimeCode / table={ caslib="CASUSER(swkuma)", name="PRICEDATA" } objOut={ { table={ caslib="CASUSER", name="outStatTemp" , replace="true" }, objRef='outStat' } } , { table={ caslib="CASUSER", name="outFcastTemp" , replace="true" }, objRef='outFcast' } seasonality=12 timeId={name='date' , FORMAT="_DATA_"} interval="Month" nlFormat=true series={'sale'} require={{pkg='TSM'}} code=' declare object myModel(TSM); declare object mySpec(ARIMASpec); rc = mySpec.Open(); ma[1] = 1; rc = mySpec.AddMAPoly(ma); rc = mySpec.SetOption("noint",1); rc = mySpec.SetOption("method","CLS"); rc = mySpec.close(); rc = myModel.Initialize(mySpec); rc = myModel.SetY(sale); rc = myModel.SetOption('lead', 12); rc = myModel.SetOption("alpha",0.05); rc = myModel.Run(); declare object outFcast(TSMFor); rc = outFcast.Collect(myModel); declare object outStat(TSMSTAT); rc = outStat.Collect(myModel); '; ERROR: A name token was expected ERROR: action runTimeCode / table = { caslib = 'CASUSER(swkuma)' , n ERROR: ame = 'PRICEDATA' } objOut = { { table = { caslib = 'CASUSER' ERROR: , name = 'outStatTemp' , replace = 'true' } , objRef = 'outS ERROR: tat' } } , { table = { caslib = 'CASUSER' , name = 'outFcastT ERROR: emp' , replace = 'true' } , objRef = 'outFcast' } seasonality ERROR: = 12 timeId = { name = 'date' , FORMAT = '_DATA_' } interval ERROR: = 'Month' nlFormat = TRUE series = { 'sale' } require = { { ERROR: pkg = 'TSM' } } code = ' declare object myModel(TS ERROR: M); declare object mySpec(ARIMASpec); r ERROR: c = mySpec.Open(); ma[1] = 1; rc = ERROR: mySpec.AddMAPoly(ma); rc = mySpec.SetOption("noint ERROR: ",1); rc = mySpec.SetOption("method","CLS"); ERROR: rc = mySpec.close(); ERROR: rc = myModel.Initialize(mySpec); rc = myModel.Set ERROR: Y(sale); rc = myModel.SetOption(' lead ', 12); ERROR: rc = myModel.SetOption("alpha",0.05); rc = ERROR: myModel.Run(); declare object outFcast(TSMFor) ERROR: ; rc = outFcast.Collect(myModel); ERROR: declare object outStat(TSMSTAT); rc = ou ERROR: tStat.Collect(myModel); ' ; ERROR: ^ NOTE: The submitted statements have been canceled.
Please help me to debug why this is coming and how to resolve this . Thanks!!
... View more
12-06-2024
06:30 AM
this is a part of migration activity . I cant give much detail .. i tried using %let to store lines as text , but due to single ' getting issue
... View more
12-06-2024
06:09 AM
Hi All
I have one requirement of migration activity where I need to store this code in a macro variables.
ods noproctitle;
ods graphics / imagemap=on;
libname _tmpcas_ cas caslib="CASUSER";
proc cas;
session %sysfunc(getlsessref(MYCAS));
loadactionset "timeData";
action runTimeCode / table={caslib="%sysfunc(getlcaslib( MYCAS))",
name="PRICEDATA"} objOut={{table={caslib="%sysfunc(getlcaslib(_tmpcas_))",
name="outStatTemp"
, replace="true"},
objRef='outStat'} , {table={caslib="%sysfunc(getlcaslib(_tmpcas_))",
name="outFcastTemp"
, replace="true"},
objRef='outFcast'} } seasonality=12 timeId={name='date', FORMAT="_DATA_"}
interval="Month" nlFormat=true series={'sale'} require={{pkg='TSM'}} code=' array diff[1]/nosymbols;
declare object myModel(TSM);
declare object mySpec(ARIMASpec);
rc = mySpec.Open( );
/* Specify differencing orders */
diff[1] = 1;
rc = mySpec.SetDiff(diff);
rc = mySpec.SetOption(''noint'',1); rc = mySpec.SetOption(''method'',''CLS'');
rc = mySpec.Close( );
/* Setup and run the TSM model object */
rc = myModel.Initialize(mySpec);
rc = myModel.SetY(sale);
rc = myModel.SetOption(''lead'',12); rc = myModel.SetOption(''alpha'',0.05);
rc = myModel.Run( );
/* Output model forecasts and estimates */
declare object outFcast(TSMFor);
rc = outFcast.Collect(myModel);
declare object outStat(TSMSTAT);
rc = outStat.Collect(myModel);
';
run;
proc print data=_tmpcas_.outStatTemp label contents="Fit statistics";
title 'Fit statistics';
run;
ods exclude all;
proc sql;
select max(date) into :maxTimeID from MYCAS.PRICEDATA;
quit;
ods exclude none;
proc sgplot data=_tmpcas_.outFcastTemp noautolegend
description="Predicted and actual values of sale";
title 'Predicted and actual values of sale';
xaxis label='date';
yaxis label='sale';
series x=date y=ACTUAL /lineattrs=(color=black) name="actual"
legendlabel="Actual";
series x=date y=PREDICT /name="predict" legendlabel="Predicted";
band x=date lower=LOWER upper=UPPER / transparency=0.5 name="pband"
legendlabel="95% Confidence Limits";
refline &maxTimeID /axis=x label="Forecast Start";
keylegend "actual" "predict" "pband" / across=4 noborder position=TopLeft
location=inside;
run;
proc delete data=_tmpcas_.outFcastTemp _tmpcas_.outStatTemp;
run;
libname _tmpcas_;
We are using these macro call to print exact same program as part of migration
for e.g
%__code(libname _tmpcas_ cas caslib="CASUSER")
%__code(proc cas)
%__code(session %sysfunc(getlsessref(MYCAS)))
%__code(loadactionset "timeData")
%__code( action runTimeCode / table={caslib="%sysfunc(getlcaslib( MYCAS))",
name="PRICEDATA"} objOut={{table={caslib="%sysfunc(getlcaslib(_tmpcas_))",
name='outStatTemp' , replace='true'}, objRef='outStat'} , {table={caslib="%sysfunc(getlcaslib(_tmpcas_))",
name="outFcastTemp" , replace="true"}, objRef='outFcast'} } seasonality=12 timeId={name='date', FORMAT="_DATA_"}
interval="Month" nlFormat=true series={'sale'} require={{pkg='TSM'}} code=' array diff[1]/nosymbols;
declare object myModel(TSM);
declare object mySpec(ARIMASpec);
rc = mySpec.Open( );
/* Specify differencing orders */
diff[1] = 1;
rc = mySpec.SetDiff(diff);
rc = mySpec.SetOption(''noint'',1);
rc = mySpec.SetOption(''method'',''CLS'');
rc = mySpec.Close( );
/* Setup and run the TSM model object */
rc = myModel.Initialize(mySpec);
rc = myModel.SetY(sale);
rc = myModel.SetOption(''lead'',12);
rc = myModel.SetOption(''alpha'',0.05);
rc = myModel.Run( );
/* Output model forecasts and estimates */
declare object outFcast(TSMFor);
rc = outFcast.Collect(myModel);
declare object outStat(TSMSTAT);
rc = outStat.Collect(myModel);%nrstr(%'))
%__code( &_procStatementVar4)
I am facing issue while storing and calling %__code( action runTimeCode .......... macro . I have use %let of each and every line too but same isue. can anyone pls suggest any wayout..
the errors I got
a. bad listing
b. open code recursion , this is because of single(') . Please help me in resolving this issue. Thanks!
... View more
12-06-2024
03:26 AM
woww! awesome this is what I was looking . thank you
... View more
12-06-2024
03:25 AM
sorry I should have explained a bit more. I got solution. thanks for checking
... View more
12-06-2024
03:23 AM
Thanks for checking. yes 3 is coming from a macro variable . I got solution for this problem
... View more
12-05-2024
05:21 PM
Hello need help in below scenario
I have one map section , where user can provide any value
map - 4, based on this value I need to print below statement
this value should print a statement like this
array ma[4]/nosymbols;
ma[1]=1;
ma[2]=2;
ma[3]=3;
ma[4]=4;
suppose if map - 3
array ma[3]/nosymbols;
ma[1]=1;
ma[2]=2;
ma[3]=3;
I need dynamic macro which will print these statement , as this part of one logic
... View more
12-04-2024
06:37 AM
Hi
I want to create a macro variable for all these title, title1 and title2 statement . where price1,Line1 , 203 and 28.9 will come from separate macro variable
title1 'Predicted and actual values of price1'; title2 '(productLine = ''Line1'', sale = 203, price = 28.39 )';
Can anyone please help??
... View more
03-09-2024
10:12 AM
Sorry , t1 t1.property_id is not having this column.. My idea was to add t3.property_value as promo_support, t3.property_value as vehicle_name, t3.property_value as levelname, add these column, but the number of column may change based on prop_Cd
... View more
03-08-2024
06:44 PM
code without macro
proc sql;
create table veh_det as
select *
from &planning_lib..SAS_member
where internal_dimension_id = -17
and internal_dim_type_id = -20;
quit;
proc sql;
select distinct property_id into:prop_id separated by ','
from &planning_lib..sas_member_property
where internal_dimension_id = -17;
quit;
%put property_id : &prop_id ;
proc sql;
select distinct property_cd into:prop_cd separated by ' '
from &planning_lib..sas_property
where property_id in (&prop_id);
quit;
%put &prop_cd;
proc sql;
create table veh_member as
select
t1.member_cd as member_id,
t2.member_nm,
t2.member_desc,
t3.property_value as promo_support,
t3.property_value as vehicle_name,
t3.property_value as levelname,
t2.valid_from_dttm,
t2.valid_to_dttm
from
veh_det t1
join &planning_lib..SAS_MEMBER_NLS t2
on
t1.member_id = t2.member_id
join &planning_lib..SAS_MEMBER_PROPERTY t3
on
t1.member_id = t3.member_id and property_id in (&prop_id);
quit;
log /;
79
80 proc sql;
81 create table veh_det as
82 select *
83 from &planning_lib..SAS_member
84 where internal_dimension_id = -17
85 and internal_dim_type_id = -20;
NOTE: Table WORK.VEH_DET created, with 12 rows and 10 columns.
86 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
87
88 proc sql;
89 select distinct property_id into:prop_id separated by ','
90 from &planning_lib..sas_member_property
91 where internal_dimension_id = -17;
92 quit;
NOTE: The PROCEDURE SQL printed page 9.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.04 seconds
cpu time 0.02 seconds
93
94 %put property_id : &prop_id ;
property_id : 27,31,32
95
96 proc sql;
97 select distinct property_cd into:prop_cd separated by ' '
98 from &planning_lib..sas_property
99 where property_id in (&prop_id);
100 quit;
NOTE: The PROCEDURE SQL printed page 10.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
101
102 %put &prop_cd;
PROMO_SUPPORT VEHICLE_TYPE LEVELNAME
103
104 proc sql;
105 create table veh_member as
106 select
107 t1.member_cd as member_id,
108 t2.member_nm,
109 t2.member_desc,
110 t3.property_value as promo_support,
111 t3.property_value as vehicle_type,
112 t3.property_value as levelname,
113 t2.valid_from_dttm,
114 t2.valid_to_dttm
115 from
116 veh_det t1
117 join &planning_lib..SAS_MEMBER_NLS t2
118 on
119 t1.member_id = t2.member_id
120 join &planning_lib..SAS_MEMBER_PROPERTY t3
121 on
122 t1.member_id = t3.member_id and property_id in (&prop_id);
NOTE: Table WORK.VEH_MEMBER created, with 35 rows and 8 columns.
123 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.13 seconds
cpu time 0.11 seconds
124
125
126 /* region: Generated postamble */
127 /* Close ODS destinations */
128 &graphterm; ;*';*";*/;run;quit;
129 quit;run;
130 ods html5 (id=web) close;
131 ods listing close;
132 %if %sysfunc(fileref(_gsfname)) lt 0 %then %do;
133 filename _gsfname clear;
NOTE: Fileref _GSFNAME has been deassigned.
134 %end;
135 %studio_capture_custom_output;
136 /* endregion */
137
here from 12records in veh_detail is converted to having 36 records in veh_member .
its 12* 3 = 36 as 3 columns is getting printed
... View more
03-08-2024
11:44 AM
Hi All
I have this query
proc sql; create table &val._member as select t1.member_cd as member_id, t2.member_nm, t2.member_desc, %do j = 1 %to %sysfunc(countw(&prop_cd)); %let prop_value = %scan(&prop_cd, &j); t3.property_value as &prop_value, %end; t2.valid_from_dttm, t2.valid_to_dttm from &val._mem_det t1 left join &planning_lib..SAS_MEMBER_NLS t2 on t1.member_id = t2.member_id left join &planning_lib..SAS_MEMBER_PROPERTY t3 on t1.member_id = t3.member_id and property_id in (&prop_id); quit;
In the highlighted do loop section prop_cd macro is having some value , whenever count > 1, loop is getting iterated and I am getting duplicates value = records* countw(&prop_cd))..
Kindly please help me to correct this.. my main aim to use do loop to resolve the columns
t3.property_value as colA,
t3.property_value as colB,
t3.property_value as colC,
like that..
... View more
03-01-2024
03:55 AM
This is working , but as I said inside this do loop I have other do loops where I am checking for date_sk.. that portion should iterate also as this Value do loop.
... View more
03-01-2024
02:35 AM
%macro generate_fact_csv;
%put Executing Macro: generate_fact_csv for fact tables;
%let launchTime = %sysfunc(time());
/* 1. Get internal dim_id based on cdl_global_preference */
proc sql;
create table dim_details as
select
t1.parameter_nm,
t1.parameter_val,
t2.hierarchy_id,
t2.internal_dimension_id
from &planning_lib..cdl_global_preference t1
inner join &planning_lib..sas_hierarchy t2
on input(t1.parameter_val, best12.) = t2.hierarchy_id
and t1.parameter_nm in ('PRODUCT','INTORG','TIME','PROMOTION')
;
quit;
proc sql;
select internal_dimension_id into:inter_dim_id separated by ' '
from dim_details;
quit;
%put inter_dim_id : &inter_dim_id;
/* 2. get dim_cd - dimesmion names */
proc sql;
create table dim_type_id_details as
select
t1.dimension_cd,
t1.dim_type_id,
t1.internal_dimension_id
from &planning_lib..sas_dimension t1
where t1.internal_dimension_id in (&inter_dim_id);
;
quit;
proc sql;
select dimension_cd into:dim_cd separated by ' '
from dim_type_id_details;
quit;
%put dimension_cd : &dim_cd;
/* 3. created table from sas_member to get prod,time,location*/
%do j = 1 %to %sysfunc(countw(&dim_cd));
%let val = %scan(&dim_cd, &j);
proc sql;
create table &val as
select member_id, member_cd, internal_dimension_id
from &planning_lib..sas_member
where internal_dimension_id =
(select internal_dimension_id from &planning_lib..sas_dimension
where dimension_cd = "&val") ;
quit;
%put dimesnion table created : &val;
%end;
/* 4. getting Fact table details for which we need to create CSV files */
proc sql noprint;
select distinct table_prefix_cd into : tab separated by ' '
from &planning_lib..cdl_fact_table;
quit;
%put tabs value are &tab;
/* loooping throgh Fact table name */
%do i = 1 %to %sysfunc(countw(&tab));
%let value = %scan(&tab, &i);
%if %sysfunc(exist(&planning_lib..&value)) %then %do;
%put &value Dataset Exists : generating CSV file;
/* get table id */
proc sql noprint;
select distinct table_id into : tab_id
from &planning_lib..cdl_fact_table
where table_prefix_cd = "&value";
quit;
%put table_id is &tab_id ;
proc sql noprint;
select distinct column_nm_cd into :column_nm separated by ','
from &planning_lib..cdl_fact_table_column
where table_id = &tab_id;
select distinct stg_id_column_nm into :sk_column_nm separated by ' '
from &planning_lib..cdl_fact_table_dimension
where table_id = &tab_id;
quit;
%put column_nm_cd are &column_nm;
%put sk_column_nm are &sk_column_nm;
/* extra col end */
/* check if _dt coloumn available in fact table */
proc sql noprint;
select name into :col_list separated by ' '
from dictionary.columns
where libname = "%upcase(&planning_lib)"
and memname = "%upcase(&value)";
quit;
%put col_list : &col_list;
%if %sysfunc(indexw(%upcase(&col_list), DATE_SK)) %then %do;
proc sql;
select distinct date_sk into :date_sk_dis separated by ' '
from &planning_lib..&value;
quit;
%put date_sk_dis = &date_sk_dis;
%do i = 1 %to %sysfunc(countw(&date_sk_dis));
%let date_dis = %scan(&date_sk_dis, &i);
/* Construct your table name */
%let value_date_dis = &value._date_dis_&date_dis;
/* create final table */
proc sql;
CREATE table &value_date_dis as
SELECT
geo.member_cd as geo_id,
prd.member_cd as prod_id,
tab.&column_nm
%if %sysfunc(indexw(%upcase(&sk_column_nm), DATE_ID)) %then %do;
, time.member_cd as date_id
%end;
%if %sysfunc(indexw(%upcase(&col_list), START_DT)) %then %do;
, tab.start_dt
,tab.end_dt
%end;
%if %sysfunc(indexw(%upcase(&sk_column_nm), VEHICLE_ID)) %then %do;
, vehicle.member_cd as vehicle_id
%end;
FROM
&planning_lib..&value AS tab
JOIN
Geography AS geo ON tab.geo_sk = geo.member_id
JOIN
product AS prd ON tab.prod_sk = prd.member_id
%if %sysfunc(indexw(%upcase(&sk_column_nm), DATE_ID)) %then %do;
JOIN
time_new AS time ON tab.date_sk = time.member_id and tab.date_sk = &date_dis
%end;
%if %sysfunc(indexw(%upcase(&sk_column_nm), VEHICLE_ID)) %then %do;
JOIN
vehicle AS veh ON tab.vehicle_sk = vehicle.member_id
%end;
;
quit;
/* Path at which csv files are stored */
%let path = /path/csv/facts;
%let valueL = %sysfunc(lowcase(&value));
/* proc export data= &value */
/* outfile="&path/ro_&valueL..csv" */
/* dbms=csv */
/* replace; */
/* run; */
%end; /* do loop end for date_sk files */
%end; /* date_sk check */
%else %do;
%put will not check for date_sk;
%end;
%end; /* if csv check end */
%else %do;
%put &value Dataset does not exists : Not generating CSV file;
%end;
%end; /* do value check end */
%let landTime = %sysfunc(time());
%let timeTaken = %sysevalf(&landTime.-&launchTime.);
%put timetaken: &timeTaken;
%mend generate_fact_csv;
%generate_fact_csv;
Here tabs value are CPRIC COST SALE FCST VEHPE FCSTE PRICE INV, but the loop only checks till SALE .. after that it is not going forward to check for FCST VEHPE FCSTE PRICE INV. Can anyone please tell me what is the issue.
%do i = 1 %to %sysfunc(countw(&tab));
%let value = %scan(&tab, &i);
... View more
02-19-2024
07:50 AM
proc sql noprint; create table &abt_worklib..input_plan_rules_1 as select trim(lowcase(a.pricing_plan_id)) as pricing_plan_id length=37, trim(lowcase(a.business_category_id)) as business_category_id label='business_category_id' length=37, &gv_current_dt. as current_date format=&gv_rd_date_sas_format. label='current_date', %if %length(&init_rec_promo_dt) eq 0 %then %do; . as initial_rec_date_promo format=&gv_rd_date_sas_format. label='initial_rec_date_promo', %end; %else %do; &init_rec_promo_dt. as initial_rec_date_promo format=&gv_rd_date_sas_format. label='initial_rec_date_promo', %end; %if %length(&last_rec_dt_promo) eq 0 %then %do; . as last_rec_date_promo format=&gv_rd_date_sas_format. label='last_rec_date_promo', %end; %else %do; &last_rec_dt_promo. as last_rec_date_promo format=&gv_rd_date_sas_format. label='last_rec_date_promo', %end; /*2 as opt_flag format=1. length=3,*/ &opt_flag. as opt_flag format=1. length=3, '' as promo_period length=500 informat=$500. format=$500., case when input(b.rule_val_1525,1.) = 0 then 5 when input(b.rule_val_1525,1.) = 1 then 4 when input(b.rule_val_1525,1.) = 2 then 1 else 0 end as obj_func_promo format=3. length=3, input(b.rule_val_1404,1.) as promo_price_grid_type format=1. length=3, input(b.rule_val_1301,1.) as is_inventory_constrained format=1. length=3, input(b.rule_val_1302,best9.) as min_discount_pct_promo format=&gv_rd_pct_sas_format., input(b.rule_val_1303,best9.) as max_discount_pct_promo format=&gv_rd_pct_sas_format., case when input(b.rule_val_1306,1.) = 1 then input(b.rule_val_1304,best9.) else . end as min_margin_pct_promo format=&gv_rd_pct_sas_format., case when input(b.rule_val_1306,1.) = 2 then input(b.rule_val_1304,best18.) else . end as min_margin_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1306,1.) = 1 then input(b.rule_val_1305,best9.) else . end as max_margin_pct_promo format=&gv_rd_pct_sas_format., case when input(b.rule_val_1306,1.) = 2 then input(b.rule_val_1305,best18.) else . end as max_margin_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1526,1.) = 1 then input(b.rule_val_1503,best18.) else . end as gross_margin_lb_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1526,1.) = 1 then input(b.rule_val_1504,best18.) else . end as gross_margin_ub_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1526,1.) = 0 or input(b.rule_val_1526,1.) = . then . else . end as gross_margin_lb_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1526,1.) = 0 or input(b.rule_val_1526,1.) = . then . else . end as gross_margin_ub_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1527,1.) = 1 then input(b.rule_val_1505,best18.) else . end as sell_through_units_lb_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1527,1.) = 1 then input(b.rule_val_1506,best18.) else . end as sell_through_units_ub_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1527,1.) = 0 or input(b.rule_val_1527,1.) = . then . else . end as sell_through_units_lb_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1527,1.) = 0 or input(b.rule_val_1526,1.) = . then . else . end as sell_through_units_ub_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1528,1.) = 1 then input(b.rule_val_1501,best18.) else . end as gross_margin_lb_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1528,1.) = 1 then input(b.rule_val_1502,best18.) else . end as gross_margin_ub_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1528,1.) = 2 then input(b.rule_val_1507,best18.) else . end as gross_margin_pct_lb_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1528,1.) = 2 then input(b.rule_val_1508,best18.) else . end as gross_margin_pct_ub_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1528,1.) = 0 or input(b.rule_val_1528,1.) = . then . else . end as gross_margin_pct_ub_promo format=&gv_rd_qty_sas_format., 1 as allow_manual_mkd format=1. length=3, 1 as allow_manual_promo_on_reg_price format=1. length=3, 1 as allow_stacked_promo_on_mkd format=1. length=3, 1 as allow_stacked_promo_on_promo format=1. length=3, 1 as allow_promo_price_below_mpp format=1. length=3, input(b.rule_val_1508,best9.) as gross_margin_pct_ub_promo format=&gv_rd_qty_sas_format. /*input(b.rule_val_516,6.) as min_periods_since_avail_dt format=&gv_rd_cnt_sas_format.*/ from &abt_worklib..pricing_plan a left join &abt_worklib..plan_rule_transposed b on upcase(a.pricing_plan_id) = upcase(b.pricing_plan_id) left join &pricing_lib..date_dm e on a.end_dt between e.fiscal_start_dt and e.fiscal_end_dt and e.date_lvl_no = &time_low_lvl. ; quit;
... View more