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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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