Date: Thu, 28 Apr 2005 14:09:52 -0700
Reply-To: cassell.david@EPAMAIL.EPA.GOV
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "David L. Cassell" <cassell.david@EPAMAIL.EPA.GOV>
Subject: Re: Filename PIPE and Datastep DOW loop
In-Reply-To: <8FCAD1A765D4C94AA90F163E1B732DF0054E96FA@tlrusmneagmbx03.erf.thomson.com>
Content-type: text/plain; charset=US-ASCII
matt.pettis@THOMSON.COM wrote:
> Thanks - this makes sense... However, different DATA step statements
> isn't really the way I want to go. This was a simple example, but
what
> I really want to do is to parse the 'nslookup-ed' name from the STDOUT
> of the 'nslookup' command from windows.
>
> The IP address is read in from a SAS dataset. My ultimate goal is to
> take a list of IP addresses, issue the 'nslookup' command with each IP
> address as an argument, and calculate a second column in the table as
> the 'looked-up' address. I was hoping to use a datastep to step
through
> my IP addresses and then use a DOW loop to issue a
>
> FILENAME NSLKUP PIPE "nslookup <IP address";
>
> And parse the STDOUT's 5th line for the address name...
I see that you already have excellent answers. But I would do this
using a pipe to funnel Perl output into my SAS DATA step. Languages
like Perl and Python are really better suited to admin tasks, and
have better error-handling.
Also, I think you want to parse the FOURTH line in the input instead
of the fifth.
And if you want to do it using the PRX... functions in the DATA step,
you could use a regex like:
re = prxparse('/[^-]+$/');
This will capture everything after the last dash, all the way to the
end of the string. You could then grab the resultant out of the
string. But if you used a pipe from a Perl program, you could
get the results without having to parse the incoming lines.
David
--
David Cassell, CSC
Cassell.David@epa.gov
Senior computing specialist
mathematical statistician