I have multiple libraries with different [z/OS] dataset names that contains identifying information. Using the 'SCAN' function I can retrieve the part of the dataset name containing the identity of the data. The problem is that I can't retrieve the dataset name. Due to some security concerns, I cannot use some of the SAS facilities like (IN=xx) to reliably determine the source of each observation without processing each dataset individually and assigning the source manually.
Can a macro variable like &lib or &libname be retrieved for each observation as it is processed so the identifying incormation can be preserved with the selected records in a single pass of multiple files (E.G. - data xx; set a b c d e...;)
What is your current code right now?
Are you using the INDSNAME option within SET statement?
I don't have any code yet. I am trying to figure out if and how to code a program.
From another program using the same data I get the following note:
NOTE: Libref DDP001 was successfully assigned as follows:
Engine: V9
Physical Name: MXGT.BIZ.CDTF.P001.SASDATA
I want to bring the Physical Name into the program so I can retrieve any of the levels of the name as the data is being read. When one of the datasets finishes, I need the name to change as the next dataset is processed.
I think sashelp.vlibname would have that information, so you could query it there.
I think that you should look at the pathname function. For example,
location = pathname('DDP001','L');
will create a string variable with the value MXGT.BIZ.CDTF.P001.SASDATA
Paul
This worked, almost. As the source of the observations changed, the value stayed the same because it is keeyed off the DDNAME. I need to know for each observation in the data. This gave the value in only one of the multiple datasets being read.
You will need to use both the indsname option and the pathname function. Let's see if I can write the code off the top of my head:
identy = scan(pathname(scan(dsn,1,'.'),'L'),3,'.');
This is not tested. I don't have a mainframe to run it on.
Paul
I admit to some curiosity as to how (IN=xxx) is a security issue as I would think the dataset name on the set statement would likely contain way more information.
I personally do not find it much of a risk, but if the JCL was changed and the dataset name did not match the data source. Someone could actually view another person or group's data. I am dealing with application data and not necessiarily computer usage data.
I put together some quick code to test.
%MACRO TESTIT ;
DATA ACTX ;
SET CDTN01.CDTF01
CDTS01.CDTF01
CDTU01.CDTF01 INDSNAME=DSN ;
KEEP IDENTITY DATE SISID TIME2 CNT ACTVY_STAT_ID
DU_TYPE_CD TECH_FNCTN_ID ;
FORMAT SISID $3.
TECH_FNCTN_ID $12. ;
CNT = 1 ;
IDENTITY = SCAN(DSN,3,".") ;
%MEND TESTIT;
%TESTIT ;
I do not get any errors, but identity is blank.
SASHELP.VLIBNAME will get the name, but I need the IDENTITY on each record.
What does DSN look like before the scan? IF the full name isn't provided there's not much you can do.
For libname - read it in, store as macro variable and assign in data step. Not efficient by doable.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.