DATA Step, Macro, Functions and more

windows 7 pipe problem

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

windows 7 pipe problem

Hello,

I have a problem with one of my macros using SAS 9.22 on Windows 7. I amrunning my programmes on different computers in different directories. ThereforeI wrote a little macro which checks the computer’s hostname and according tothis name assigns my library to a certain directory. I do the following to putthe hostname into a macro variable:

FILENAME h PIPE 'hostname';

DATA_NULL_;

      INFILE h;

      INPUT;

      PUT _infile_ ;

      CALL SYMPUT('current_com',TRIM(LEFT(_infile_)));

RUN;

This works with Win XP and SAS 9.22. Here is what thelog says:

NOTE:The infile H is:

      Unnamed Pipe Access Device,

      PROCESS=hostname,RECFM=V,LRECL=256

myhostname

NOTE: 1record was read from the infile H.

      The minimum record length was 10.

      The maximum record length was 10.

NOTESmiley Very HappyATA statement used (Total process time):

      real time           0.09 seconds

      user cpu time       0.00 seconds
      system cpu time     0.00 seconds


However, on Windows 7 I obtain:

NOTE:The infile H is:

      Unnamed Pipe Access Device,

      PROCESS=hostname,RECFM=V,LRECL=256

NOTE: 0records were read from the infile H.

NOTESmiley Very HappyATA statement used (Total process time):

real time           0.31 seconds
cpu time            0.04 seconds

So apparently the hostname couldn’t be read. If I type ‘hostname’in the windows console I get the hostname as expected.

P.S. I apologise if this isn't the correct forum section. It seems most appropriate


Accepted Solutions
Solution
‎10-25-2011 07:05 AM
Valued Guide
Posts: 2,177

windows 7 pipe problem

not having win7, I couldn't predict that result.

Similarly %sysget(hostname) failed on my win-vista as the %hostname% does not exist here either.

For that reason I had developed the step to load all current env-vars.

Your experience on win-7 matches the usage note at

http://support.sas.com/kb/41/863.html

Problem Note 41863: Problems using the PIPE engine in Windows 7 x64 operating system

Perhaps the suggestions will work for you

good luck

peter    

View solution in original post


All Replies
PROC Star
Posts: 7,492

Re: windows 7 pipe problem

Out of curiosity:  what happens when you type hostname in the Windows 7 command prompt?

Trusted Advisor
Posts: 1,301

windows 7 pipe problem

If all you are doing here is gather the hostname why not just use the automatic macro variable syshostname?

Occasional Contributor
Posts: 17

windows 7 pipe problem

Because I wasn't aware of this macro variable :smileysilly: Using syshostname works, thanks! I still would like to find out what is wrong with my original code, though. Maybe my response to Peter.C gives a lead...

Occasional Contributor
Posts: 17

windows 7 pipe problem

It gives me the hostname, assuming that what you call 'command prompt' is what I called 'windows console' (cmd.exe).

Valued Guide
Posts: 2,177

windows 7 pipe problem

if the FriedEgg suggestion above provides the wrong information for &SYSHOSTNAME, here is some testing code to load ALL environment variables into SAS table named work.EVARS.

%put &syshostname;

%put %sysget(hostname);

data evars ;

   filename envs pipe 'set' ;

   length name $50  value $1024  check $6 ;

   format name $20. value $100. ;

   infile envs truncover length=l lrecl=10000 col=c dlm= '=';

   input  name @ ;

   if c>=l then value=' ';

           else value = substr( _infile_, c ) ;

   check = scan( 'ok#wider!', (( l-c) > 1024)+1, '#' ) ;

run ;

Probably the full list of these will vary for each op.sys and possible each install. I expect you will see some name that is consistently correct.

Just load the one you want with

%let current_com = %sysget(correct_environment_variable_name) ;

Occasional Contributor
Posts: 17

Re: windows 7 pipe problem

Many thanks for your reply. Unfortunately your code doesn’t work. First, %put %sysget(hostname); gives a warning on XP as well as on Win7:


WARNING: The argument to macro function %SYSGET is not defined as a system variable.


The datastep afterwards works on XP but not on Win 7. The error message is similar to the one in my original post:


NOTE:The infile ENVS is:

      Unnamed Pipe Access Device,

      PROCESS=set,RECFM=V,LRECL=10000

Stderr output:

The handle is invalid.

The handle is invalid.

(More handle invalid lines)
The handle is invalid.

NOTE: 0 records were read from the infile ENVS.

NOTE: The data set WORK.EVARS has 0 observations and 3 variables.

NOTE: DATA statement used (Total process time):

      real time           0.14 seconds

      user cpu time       0.01 seconds

      system cpu time     0.03 seconds

Maybe I should mention that, unlike XP, the Win 7 installation is 64 bit.

Solution
‎10-25-2011 07:05 AM
Valued Guide
Posts: 2,177

windows 7 pipe problem

not having win7, I couldn't predict that result.

Similarly %sysget(hostname) failed on my win-vista as the %hostname% does not exist here either.

For that reason I had developed the step to load all current env-vars.

Your experience on win-7 matches the usage note at

http://support.sas.com/kb/41/863.html

Problem Note 41863: Problems using the PIPE engine in Windows 7 x64 operating system

Perhaps the suggestions will work for you

good luck

peter    

Occasional Contributor
Posts: 17

Re: windows 7 pipe problem

Thanks for pointing me to the usage note. Pinning SAS to the task bar resolves the issue.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 3110 views
  • 3 likes
  • 4 in conversation