Hi everybody.
I'm wondering if it's possible to select the viya formatlibrary when I'm transferring data from EG to VIYA?
As it is now we share a VIYA platform with different business units across our business, and as a result our formats must be prefixed.
For example in EG we have a format called $gender but on VIYA it's called $pv_gender. When I upload my data to VIYA it obviously needs to recognize the prefixed format.
Below is the code I use for the datatransfer.
%let CAS_lib = "*/*mycaslib*/";
/* Create CAS session */
cas CAS_session host="/*our business server*/" port=5570;
options casncharmultiplier=1.5;
/* Access the data for VIYA CAS */
LIBNAME MY_CAS CAS CASLIB=&CAS_lib PORT=5570 SERVER="/*our business server*/" ;
/* Replace target table requested: Drop session table */
proc casutil sessref=CAS_session;
droptable casdata='DM_assignment_spb' incaslib=&CAS_lib quiet;
quit;
/* Replace target table requested: Drop global table */
proc casutil sessref=CAS_session;
droptable casdata='DM_assignment_spb' incaslib=&CAS_lib quiet;
quit;
/*Our data goes in here*/
data MY_CAS.DM_assignment_spb(promote=yes);
set DM_assignment_spb;
run;
/* PROC CASUTIL: SAVE CASDATA */
proc casutil incaslib=&CAS_lib outcaslib=&CAS_lib sessref=CAS_session;
save casdata='DM_assignment_spb'
replace;
quit;
/* Terminate CAS session */
cas CAS_session terminate;
You could to the following, see code sample below with comments.
/*
* load data to CAS
* take away the format for var sex to avoid any errors
*/
data casuser.class(promote=yes);
set class;
format sex;
run;
/*
* check what it looks like
*/
proc cas;
action table.columninfo / table={caslib="casuser" name="class"};
run;
quit;
/*
* add the proper format again
*/
proc cas;
action table.alterTable /
caslib="casuser"
name="class"
columns={
{format="$pv_gender" name="sex"}
}
;
run;
quit;
/*
* check again
*/
proc cas;
action table.columninfo / table={caslib="casuser" name="class"};
run;
quit;
Please note, that the format has to be available on the CAS server
The better solution for such issues is not to use different format names, but different format catalogs, for which you only need to set the fmtsearch option in the autoexec for the respective business unit.
You could to the following, see code sample below with comments.
/*
* load data to CAS
* take away the format for var sex to avoid any errors
*/
data casuser.class(promote=yes);
set class;
format sex;
run;
/*
* check what it looks like
*/
proc cas;
action table.columninfo / table={caslib="casuser" name="class"};
run;
quit;
/*
* add the proper format again
*/
proc cas;
action table.alterTable /
caslib="casuser"
name="class"
columns={
{format="$pv_gender" name="sex"}
}
;
run;
quit;
/*
* check again
*/
proc cas;
action table.columninfo / table={caslib="casuser" name="class"};
run;
quit;
Please note, that the format has to be available on the CAS server
Thank you! It works now 🙂
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.