Desktop productivity for business analysts and programmers

long var with multiple delimiter

Reply
Regular Contributor
Posts: 225

long var with multiple delimiter

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[r15sSmiley Tongueg] " "" -1 "" -1 0 "" 0 0 "" 2508 "" 0 "" 0.000000 0.00 0.00 0.00 0.00 1 "servername.com"

 

 

Super User
Posts: 13,889

Re: long var with multiple delimiter


sas_9 wrote:

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

 


What is a "stranger" in this context?

Respected Advisor
Posts: 4,779

Re: long var with multiple delimiter

@sas_9 How would your desired result look like?

Regular Contributor
Posts: 225

Re: long var with multiple delimiter

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 -

Respected Advisor
Posts: 4,779

Re: long var with multiple delimiter

@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.

Respected Advisor
Posts: 4,779

Re: long var with multiple delimiter

@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?

Regular Contributor
Posts: 225

Re: long var with multiple delimiter

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. 

Respected Advisor
Posts: 4,779

Re: long var with multiple delimiter

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

Regular Contributor
Posts: 225

Re: long var with multiple delimiter

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.  

Regular Contributor
Posts: 225

Re: long var with multiple delimiter

attaching full log file with 2 records as an example, 

Ask a Question
Discussion stats
  • 9 replies
  • 220 views
  • 0 likes
  • 3 in conversation