BookmarkSubscribeRSS Feed
MandM
Fluorite | Level 6

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...;)

10 REPLIES 10
Reeza
Super User

What is your current code right now?

 

Are you using the INDSNAME option within SET statement?

MandM
Fluorite | Level 6

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.

 

Reeza
Super User

I think sashelp.vlibname would have that information, so you could query it there. 

 

Paul_OldenKamp_org
Obsidian | Level 7

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

MandM
Fluorite | Level 6

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.

Paul_OldenKamp_org
Obsidian | Level 7

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

ballardw
Super User

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.

 

MandM
Fluorite | Level 6

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.  

MandM
Fluorite | Level 6

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.

Reeza
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 10 replies
  • 1380 views
  • 0 likes
  • 4 in conversation