%macro chk_dir(dir=);
data _null_;
/*_dir=strip("&dir");*/
sti=scan("&dir",-1,'\');
folder=reverse(subpad(reverse("&dir"),index(reverse("&dir"),'\')+1));
newdir1=dcreate(sti,folder);
if newdir1 ne '' then
put "NOTE: Directory &dir is created";
run;
%mend chk_dir;
%MACRO DOWNLOAD_SAS_BIB(DSN);
%let path=c:\new;
%chk_dir(dir=&path.\&DSN);
LIBNAME OUTME "&path.\&DSN";
OPTIONS VALIDVARNAME=any;
%SYSLPUT DSN=&DSN;
RSUBMIT;
OPTIONS VALIDVARNAME=any;
LIBNAME GETME "&DSN." DISP=OLD;
OPTIONS OBS=MAX;
PROC DOWNLOAD INLIB=GETME OUTLIB=OUTME V6TRANSPORT;
RUN;
LIBNAME GETME CLEAR;
ENDRSUBMIT;
%MEND DOWNLOAD_SAS_BIB;
%MACRO TEST1(BIB);
OPTIONS COMAMID = TCP;
signon Rsysv user="&_host_user" password="&_host_pass" noscript;
%DOWNLOAD_SAS_BIB(&BIB.);
%END;
%MEND TEST1;
%TEST1(SKJH.UVT.SAS);
%TEST1(SB24.NEW.SAS);
What I am doing in this program is I am downloading the SAS dataset from mainframe to windows
When I am running the program with this dataset SKJH.UVT.SAS it is running fine
but when I am running with this dataset SB24.NEW.SAS it shows me the error
ERROR: Cannot open data library GETME because it is uninitialized and user has only read access.
What I am thinking the error is beacuse this dataset SB24.NEW.SAS when I am opening in mainframe it shows me the error:Invalid block size it is empty and having block size and record length =0
can somebody help me what changes should I make in my code so that when i have dataset with block size and record length =0 it should not run proc download step and program should not be in error
You don't need DISP = OLD on the LIBNAME you are only reading from DISP = SHR is all you need. Why are you using the V6TRANSPORT option? Removing that will enable SAS to convert the datasets correctly for you.
I took the liberty of editing your code so that it is easier to read. Note that you have a suprlus %END in macro TEST1.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.