DATA Step, Macro, Functions and more

how to exstact data from unix

Reply
Contributor
Posts: 45

how to exstact data from unix

I have 2 data set filea fileb

filea fileb
filename filename
a1 b1
a2 b2
a3 b3
a4 b4
a5 b5
a6 b6
a7 b7
a8 b8

I have to exstact data from unix as per filename

below mention path

x>y>z>a1>l

-rwxrwxr-x 1 x binary 173922 Feb 8 07:20 a1_07-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 9 05:18 a1_08-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 10 05:35 a1_09-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 11 05:41 a1_10-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 12 08:31 a1_11-02-2011_status. log

x>y>z>a2>l

-rwxrwxr-x 1 x binary 173922 Feb 8 07:20 a2_07-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 9 05:18 a2_08-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 10 05:35 a2_09-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 11 05:41 a2_10-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 12 08:31 a2_11-02-2011_status. log

x>y>z>b1>l
-rwxrwxr-x 1 x binary 173922 Feb 8 07:20 b1_07-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 9 05:18 b1_08-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 10 05:35 b1_09-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 11 05:41 b1_10-02-2011_status. log
-rwxrwxr-x 1 x binary 173922 Feb 12 08:31 b1_11-02-2011_status. log


I need to create a data set filec which is like

filec
filename
a1_07-02-2011_status
a1_08-02-2011_status
a1_09-02-2011_status
a1_10-02-2011_status
a1_11-02-2011_status
a2_07-02-2011_status
a2_08-02-2011_status
a2_09-02-2011_status
a2_10-02-2011_status
a2_11-02-2011_status
b1_07-02-2011_status
b1_08-02-2011_status
b1_09-02-2011_status
b1_10-02-2011_status
b1_11-02-2011_status





Please help me
Valued Guide
Posts: 2,174

Re: how to exstact data from unix

I presume you know what command will list your file system hierarchy as you show in the posting. That is the command whose output a data step can read and parse
roam through support.sas.com for examples and samples of
filename pipe (see http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#pipe.htm )
function scan()
(for example
filename = scan( data, -2, '. ' ) ;
would use delimiters dot and blank, to extract the second last string from string "data" .

filename files_l pipe "your command" ;
data your_data_with_filenames ;
length filename $200 ;
infile files_l truncover ;
input ;
if scan( _infile_, -1, '. ' ) ='log' ;
* ignoring lines which do not finish "log" ;
filename = scan( _infile_, -2, '. ' ) ;
run;
Contributor
Posts: 45

Re: how to exstact data from unix

we are using a macro to connect the unix environment .

So please solve my problem
Valued Guide
Posts: 2,174

Re: how to exstact data from unix

If you want this added to your macro, and you can't see how to do it, and so you want us to do it, then you need to reveal your macro
Valued Guide
Posts: 2,174

Re: how to exstact data from unix

If you want this added to your macro, and you can't see how to do it, and so you want us to do it, then you need to reveal your macro
Valued Guide
Posts: 2,174

Re: how to exstact data from unix

odd repetition of msg., deleted - Peter.C
Ask a Question
Discussion stats
  • 5 replies
  • 139 views
  • 0 likes
  • 2 in conversation