DATA Step, Macro, Functions and more

Determine observation source

Reply
Occasional Contributor
Posts: 9

Determine observation source

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...Smiley Wink

Super User
Posts: 17,784

Re: Determine observation source

What is your current code right now?

 

Are you using the INDSNAME option within SET statement?

Occasional Contributor
Posts: 9

Re: Determine observation source

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.

 

Super User
Posts: 17,784

Re: Determine observation source

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

 

Contributor
Posts: 20

Re: Determine observation source

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

Occasional Contributor
Posts: 9

Re: Determine observation source

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.

Contributor
Posts: 20

Re: Determine observation source

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

Super User
Posts: 10,484

Re: Determine observation source

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.

 

Occasional Contributor
Posts: 9

Re: Determine observation source

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.  

Occasional Contributor
Posts: 9

Re: Determine observation source

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.

Super User
Posts: 17,784

Re: Determine observation source

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.

Ask a Question
Discussion stats
  • 10 replies
  • 391 views
  • 0 likes
  • 4 in conversation