BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MVras
Calcite | Level 5

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;
1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

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

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

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.

BrunoMueller
SAS Super FREQ

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

MVras
Calcite | Level 5

Thank you! It works now 🙂

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!

Discussion stats
  • 3 replies
  • 3634 views
  • 0 likes
  • 3 in conversation