BookmarkSubscribeRSS Feed
arpit
Calcite | Level 5
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
5 REPLIES 5
Peter_C
Rhodochrosite | Level 12
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;
arpit
Calcite | Level 5
we are using a macro to connect the unix environment .

So please solve my problem
Peter_C
Rhodochrosite | Level 12
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
Peter_C
Rhodochrosite | Level 12
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
Peter_C
Rhodochrosite | Level 12
odd repetition of msg., deleted - Peter.C

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1132 views
  • 0 likes
  • 2 in conversation