BookmarkSubscribeRSS Feed
sas_9
Obsidian | Level 7

how would I read two strangers below as 2 separate variable?

 

 

 

"SAS Enterprise Guide_SASApp - Workspace Server_70784B87-149E-AE47-BCE0-B331CF4E6EFF"

 

 

"SAS Enterprise Guide_SASApp - Workspace Server_123456jsdjh-12rfg-grr-BCE0-DSLKFMLKDS" "/SAS/WORKSPACE/SERVER/DIR/WorkspaceServer.sh -noterminal -noxcmd -netencryptalgorithm AES -metaserver servername.com -metaport 123456 -metarepository Foundation -locale en_US -objectserver -objectserverparms ""delayconn sph=servername.com protocol=bridge 6.852563 4700 0 -1 0 0 1894 0 0 0 32 -1 0 0 0 515049 4 -1 "" "default" 9 1 "" "" 0 1441792 0 "" "" "" "" 0 "" 15 "" -1 "/userid" "" "" "" -1 "" "" 16 "" 1511905439 "" "" 0 0 -1 0 362496 "select[type == any] order[r15s:pg] " "" -1 "" -1 0 "" 0 0 "" 2508 "" 0 "" 0.000000 0.00 0.00 0.00 0.00 1 "servername.com"

 

 

9 REPLIES 9
ballardw
Super User

@sas_9 wrote:

how would I read two strangers below as 2 separate variable?

 


What is a "stranger" in this context?

Patrick
Opal | Level 21

@sas_9 How would your desired result look like?

sas_9
Obsidian | Level 7

so VARIABLE1 and VARIABLE2 should look like (2 variables with one observation)

 

VARIABLE1

"SAS Enterprise Guide_SASApp - Workspace Server_70784B87-149E-AE47-BCE0-B331CF4E6EFF"

 

VARIABLE2 

"SAS Enterprise Guide_SASApp - Workspace Server_123456jsdjh-12rfg-grr-BCE0-DSLKFMLKDS" "/SAS/WORKSPACE/SERVER/DIR/WorkspaceServer.sh -noterminal -noxcmd -netencryptalgorithm AES -metaserver servername.com -metaport 123456 -metarepository Foundation -locale en_US -objectserver -objectserverparms ""delayconn sph=servername.com protocol=bridge 6.852563 4700 0 -1 0 0 1894 0 0 0 32 -1 0 0 0 515049 4 -1 "" "default" 9 1 "" "" 0 1441792 0 "" "" "" "" 0 "" 15 "" -1 "/userid" "" "" "" -1 "" "" 16 "" 1511905439 "" "" 0 0 -1 0 362496 "select[type == any] order[r15sSmiley Tongueg] " "" -1 "" -1 0 "" 0 0 "" 2508 "" 0 "" 0.000000 0.00 0.00 0.00 0.00 1 "servername.com"

 

Thank you -

Patrick
Opal | Level 21

@sas_9

It wouldn't be a problem to post code for the data you've provided. But is this a representative sample?

Could we use an empty line as delimiter? Or the string "SAS Enterprise Guide ?

 

Ideally attach a text file with some more sample data for us to better understand what we're dealing with.

Patrick
Opal | Level 21

@sas_9  Not knowing what you want to do but as this looks like log: Have you already checked out what the SAS Environment Manager could do for you?

sas_9
Obsidian | Level 7

Thanks Patrick - infect i am reading one log file which has user executed job details and in that file (each value is separated by space) there are two long strings which i want to represent appropriately (sample attached). File has character strings In quotation mark. However, here, first string contains all in one quotation mark but second string is really long string which contains multiple quotation mark + different sign in between (like - / '@', etc..) but all the time it ends with like -> -METAPASS  74785249857DSJVBSDJHB"

 

I am not that familiar with SAS EVM but this would be a big plus for me whenever user stats require, Thank you. 

Patrick
Opal | Level 21

@sas_9

The following code works for the sample you've posted.

data sample;
  infile 'c:\temp\log-file.txt' truncover lrecl=1300;
  input ;

  length var1 $200 var2 $1000;
  retain _prxid 0;
  if _n_=1 then
    do;
      _prxid=prxparse('/^("[^"]*")\s*(.*-METAPASS[^"]*")$/oi');
    end;

  if prxmatch(_prxid,strip(_infile_)) then
    do;
      call prxposn(_prxid, 1, _pos, _len);
      var1=substrn(_infile_,_pos,_len);
      call prxposn(_prxid, 2, _pos, _len);
      var2=substrn(_infile_,_pos,_len);
    end;
  run;

 

There aren't any end-of-line indicators in your sample data but not sure if this is just because you've only posted a single "record".

Shouldn't you have any end-of-line indicators in your log file then reading the data would need to be a bit different (data stream).

sas_9
Obsidian | Level 7

Thanks Patrick. All lines in log file start with "JOB_<USERID>" and ends with that huge string which has -METAPASS 86896JKJHGJUHVBHB (-METAPASS and encrypted password), so that is a start and end point for each record.  

sas_9
Obsidian | Level 7

attaching full log file with 2 records as an example, 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 2393 views
  • 0 likes
  • 3 in conversation