BookmarkSubscribeRSS Feed
Rakesh21
Calcite | Level 5

Hi,

We are executing the below code to creating some temporary libraries dinamically(L1,L2....)

we are able to see the libraries but we are didnt find any data under that libraries.

can you please provide some code to extract the datasets/views it to that libraries.

 

%let banames="";
        proc sql noprint;
            SELECT cats("'", TARGET_BA_SCHEMA_NAME, "'")as BA_SCHEMA_NAME,
                BA_OBJ_ID format=15., BA_OBJ_VER, BA_COMPANY_ID,
                SAS_LIB_NAME,DATA_SENSITIVITY,cats("'",SNAPSHOT_LABEL,"'") as snapshot_label
     into :banames separated by
                '#', :baobjid separated by '#', :baobjver separated by '#',
                :bacompid separated by '#', :libnm separated by '#',
                :dsblind separated by '#',:snplbl separated by '#' FROM ba_dtl WHERE
                process_log_id in (SELECT MAX(process_log_id) FROM ba_dtl
                GROUP BY target_location, archival_folder) and sas_lib_name is not null;
        quit;

      


  %let rwcnt = %sysfunc(countw(&banames, "#"));
        %if &rwcnt >=1 %then
            %do;
    %let flg=0;
                %do i=1 %to &rwcnt.;
               
                    %let compid = %scan(&bacompid, &i., "#");
                    %let objid = %scan(&baobjid, &i., "#");
                    %let objvr = %scan(&baobjver, &i., "#");
                    %let baname = %scan(&banames, &i., "#");

           
                
                   
                    %let snaplbl = %scan(&snplbl, &i., "#");
                    %let lbnme = %scan(&libnm, &i., "#");


                            %put &baname &snaplbl &dsbln;
                            LIBNAME &lbnme oracle USER=&usr PASS="&pwd" PATH=&dbname
       dbconinit="BEGIN Pkg_Business_Area.SP_Initialize_BA(&BAName,&snaplbl,&dsbln); END;";
/*                        %end;*/
                %end;
         %end;

 %mend ba_init;
 %ba_init;

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I can think of two possibilites:

1) The user details provided don't have access to those schemas.

2) The code which is being generated is not correct, maybe spaces or something like that.

 

Now 1 can be checked easily byt doing a simple proc sql select * from connection to oracle ... just select from something you hard code in for a run.

 

Number 2 however is not something we could chek from what is provided.  You need to look at what code is generated from this macro, take some of the log where macro is de-referenced.  Then run look at this and see if it is correct and points to an existing area.

Using macro variables you can find things like spaces creep in, for example:

(&BAName,&snaplbl,&dsbln)

If BAName has a trailing blank and snaplbl is abc, then you might see:

DEF abc

which may not be valid if you want:

DEFabc

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 367 views
  • 0 likes
  • 2 in conversation