From: data _null_; on
On Jul 29, 3:06 am, RolandRB <rolandbe...(a)hotmail.com> wrote:
> On 28 Jul., 23:01, "Richard A. DeVenezia" <rdevene...(a)gmail.com>
> wrote:
>
>
>
>
>
> > On Jul 28, 12:42 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > On Jul 28, 1:53 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > > Is there no sashelp.v---- view for environment variables that gives a
> > > > list of environment variable names and their contents? I can't see one
> > > > among the list in sashelp. It's easy enough to write something for
> > > > this but I was kind of expecting to find it in sashelp.
>
> > > So I wrote a macro but when I run it on my laptop which has Windows 7
> > > 64 bit on it with me having installed SAS/LE 4.1 in compatibility mode
> > > I get the following. Forst the macro and then the message. Any ideas?
>
> > Roland,
>
> > Instead of using a macro and explicit filename and data steps, try
> > creating a DATA Step view that creates the pipe, reads it, parses the
> > name=value and outputs pertinent rows.
>
> > ----------
> > data sasuser.venv / view=sasuser.venv;
>
> >   length _fref $8 _buffer $500;
>
> >   rc = filename(_fref, 'SET', 'PIPE');
> >   _fid = fopen (_fref, 'S');
>
> >   do while (fread(_fid) = 0);
> >     rc = fget(_fid, _buffer, 500);
> >     _eq = index (_buffer, '=');
> >     if _eq > 1 then do;
> >       name = substr(_buffer,1,_eq-1);
> >       value = substr (_buffer, _eq+1);
> >       OUTPUT;
> >     end;
> >   end;
>
> >   rc = filename(_fref);
>
> >   drop rc _:;
> > run;
>
> > data _null_;
> >   set sasuser.venv;
> >   put name= @35 value=;
> > run;
> > ----------
>
> > With proper credentials, you could install the view as SASHELP.VENV.
>
> > Richard A. DeVeneziahttp://www.devenezia.com
>
> Thanks for that but I am still wondering why it works on my machine at
> work yet does not work on my Windows 7 laptop at home.- Hide quoted text -
>
> - Show quoted text -

As with many PIPE related issues "what happens when you type SET in a
dos box?"

The google translation of the message "The handle is invalid validly"
is interesting.
From: RolandRB on
On 29 Jul., 13:42, "data _null_;" <datan...(a)gmail.com> wrote:
> On Jul 29, 3:06 am, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
>
>
>
>
> > On 28 Jul., 23:01, "Richard A. DeVenezia" <rdevene...(a)gmail.com>
> > wrote:
>
> > > On Jul 28, 12:42 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > > On Jul 28, 1:53 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > > > Is there no sashelp.v---- view for environment variables that gives a
> > > > > list of environment variable names and their contents? I can't see one
> > > > > among the list in sashelp. It's easy enough to write something for
> > > > > this but I was kind of expecting to find it in sashelp.
>
> > > > So I wrote a macro but when I run it on my laptop which has Windows 7
> > > > 64 bit on it with me having installed SAS/LE 4.1 in compatibility mode
> > > > I get the following. Forst the macro and then the message. Any ideas?
>
> > > Roland,
>
> > > Instead of using a macro and explicit filename and data steps, try
> > > creating a DATA Step view that creates the pipe, reads it, parses the
> > > name=value and outputs pertinent rows.
>
> > > ----------
> > > data sasuser.venv / view=sasuser.venv;
>
> > >   length _fref $8 _buffer $500;
>
> > >   rc = filename(_fref, 'SET', 'PIPE');
> > >   _fid = fopen (_fref, 'S');
>
> > >   do while (fread(_fid) = 0);
> > >     rc = fget(_fid, _buffer, 500);
> > >     _eq = index (_buffer, '=');
> > >     if _eq > 1 then do;
> > >       name = substr(_buffer,1,_eq-1);
> > >       value = substr (_buffer, _eq+1);
> > >       OUTPUT;
> > >     end;
> > >   end;
>
> > >   rc = filename(_fref);
>
> > >   drop rc _:;
> > > run;
>
> > > data _null_;
> > >   set sasuser.venv;
> > >   put name= @35 value=;
> > > run;
> > > ----------
>
> > > With proper credentials, you could install the view as SASHELP.VENV.
>
> > > Richard A. DeVeneziahttp://www.devenezia.com
>
> > Thanks for that but I am still wondering why it works on my machine at
> > work yet does not work on my Windows 7 laptop at home.- Hide quoted text -
>
> > - Show quoted text -
>
> As with many PIPE related issues "what happens when you type SET in a
> dos box?"
>
> The google translation of the message "The handle is invalid validly"
> is interesting.- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

It works fine in the DOS box. It also works fine using an "x" command.
But it won't assign a file handle to it. The macro works fine using
SAS 9.2 on the Windows server at work which I think is XP
Professional. It just won't work on my 64 bit Windows 7 laptop running
SAS/LE 4.1 in compatibility mode.

"Das Handle ist ungültig" = "The handle is invalid". I guess it would
be "Invalid file handle" if it were an English version.

Perhaps it has got something to do sas trying to use the Windows 32
bit API.
From: Tom Abernathy on
On Jul 29, 8:41 am, RolandRB <rolandbe...(a)hotmail.com> wrote:
> On 29 Jul., 13:42, "data _null_;" <datan...(a)gmail.com> wrote:
>
>
>
>
>
> > On Jul 29, 3:06 am, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > On 28 Jul., 23:01, "Richard A. DeVenezia" <rdevene...(a)gmail.com>
> > > wrote:
>
> > > > On Jul 28, 12:42 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > > > On Jul 28, 1:53 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > > > > Is there no sashelp.v---- view for environment variables that gives a
> > > > > > list of environment variable names and their contents? I can't see one
> > > > > > among the list in sashelp. It's easy enough to write something for
> > > > > > this but I was kind of expecting to find it in sashelp.
>
> > > > > So I wrote a macro but when I run it on my laptop which has Windows 7
> > > > > 64 bit on it with me having installed SAS/LE 4.1 in compatibility mode
> > > > > I get the following. Forst the macro and then the message. Any ideas?
>
> > > > Roland,
>
> > > > Instead of using a macro and explicit filename and data steps, try
> > > > creating a DATA Step view that creates the pipe, reads it, parses the
> > > > name=value and outputs pertinent rows.
>
> > > > ----------
> > > > data sasuser.venv / view=sasuser.venv;
>
> > > >   length _fref $8 _buffer $500;
>
> > > >   rc = filename(_fref, 'SET', 'PIPE');
> > > >   _fid = fopen (_fref, 'S');
>
> > > >   do while (fread(_fid) = 0);
> > > >     rc = fget(_fid, _buffer, 500);
> > > >     _eq = index (_buffer, '=');
> > > >     if _eq > 1 then do;
> > > >       name = substr(_buffer,1,_eq-1);
> > > >       value = substr (_buffer, _eq+1);
> > > >       OUTPUT;
> > > >     end;
> > > >   end;
>
> > > >   rc = filename(_fref);
>
> > > >   drop rc _:;
> > > > run;
>
> > > > data _null_;
> > > >   set sasuser.venv;
> > > >   put name= @35 value=;
> > > > run;
> > > > ----------
>
> > > > With proper credentials, you could install the view as SASHELP.VENV..
>
> > > > Richard A. DeVeneziahttp://www.devenezia.com
>
> > > Thanks for that but I am still wondering why it works on my machine at
> > > work yet does not work on my Windows 7 laptop at home.- Hide quoted text -
>
> > > - Show quoted text -
>
> > As with many PIPE related issues "what happens when you type SET in a
> > dos box?"
>
> > The google translation of the message "The handle is invalid validly"
> > is interesting.- Zitierten Text ausblenden -
>
> > - Zitierten Text anzeigen -
>
> It works fine in the DOS box. It also works fine using an "x" command.
> But it won't assign a file handle to it. The macro works fine using
> SAS 9.2 on the Windows server at work which I think is XP
> Professional. It just won't work on my 64 bit Windows 7 laptop running
> SAS/LE 4.1 in compatibility mode.
>
> "Das Handle ist ungültig" = "The handle is invalid". I guess it would
> be "Invalid file handle" if it were an English version.
>
> Perhaps it has got something to do sas trying to use the Windows 32
> bit API.

Did you try using the command string of "cmd /c set"? It might force
SAS to open a new shell and get it to work.
From: Tom Abernathy on
You can simplify the input code by using the = as a delimiter on the
INFILE statement.

data envars;
length name $32 value $1024;
command = 'SET';
infile dummy pipe filevar=command dlm='=' truncover end=eof
lrecl=2048;
do while(not eof);
input name value $char1024. ;
output;
end;
stop;
keep name value;
run;


On Jul 29, 7:29 am, "data _null_;" <datan...(a)gmail.com> wrote:
> On Jul 28, 4:01 pm, "Richard A. DeVenezia" <rdevene...(a)gmail.com>
> wrote:
>
>
>
>
>
> > On Jul 28, 12:42 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > On Jul 28, 1:53 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > > Is there no sashelp.v---- view for environment variables that gives a
> > > > list of environment variable names and their contents? I can't see one
> > > > among the list in sashelp. It's easy enough to write something for
> > > > this but I was kind of expecting to find it in sashelp.
>
> > > So I wrote a macro but when I run it on my laptop which has Windows 7
> > > 64 bit on it with me having installed SAS/LE 4.1 in compatibility mode
> > > I get the following. Forst the macro and then the message. Any ideas?
>
> > Roland,
>
> > Instead of using a macro and explicit filename and data steps, try
> > creating a DATA Step view that creates the pipe, reads it, parses the
> > name=value and outputs pertinent rows.
>
> > ----------
> > data sasuser.venv / view=sasuser.venv;
>
> >   length _fref $8 _buffer $500;
>
> >   rc = filename(_fref, 'SET', 'PIPE');
> >   _fid = fopen (_fref, 'S');
>
> >   do while (fread(_fid) = 0);
> >     rc = fget(_fid, _buffer, 500);
> >     _eq = index (_buffer, '=');
> >     if _eq > 1 then do;
> >       name = substr(_buffer,1,_eq-1);
> >       value = substr (_buffer, _eq+1);
> >       OUTPUT;
> >     end;
> >   end;
>
> >   rc = filename(_fref);
>
> >   drop rc _:;
> > run;
>
> > data _null_;
> >   set sasuser.venv;
> >   put name= @35 value=;
> > run;
> > ----------
>
> > With proper credentials, you could install the view as SASHELP.VENV.
>
> > Richard A. DeVeneziahttp://www.devenezia.com
>
> Is there a reason you choose the FILE IO functions over a "regular"
> INFILE/INPUT with FILEVAR option to avoid using the FILENAME
> statement?
>
> data sasuser.venv / view=sasuser.venv;
>    length name $32 value $1024;
>    command = 'SET';
>    infile dummy pipe filevar=command end=eof lrecl=2048;
>    do while(not eof);
>       input;
>       index = indexC(_infile_,'=');
>       if index then do;
>          name  = substr(_infile_,1,index-1);
>          value = substr(_infile_,index+1);
>          output;
>          end;
>       end;
>    stop;
>    keep name value;
>    run;
> data _null_;
>    set sasuser.venv;
>    put name= @35 value=;
>    run;

From: RolandRB on
On Jul 31, 4:04 am, Tom Abernathy <tom.aberna...(a)gmail.com> wrote:
> On Jul 29, 8:41 am, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
>
>
> > On 29 Jul., 13:42, "data _null_;" <datan...(a)gmail.com> wrote:
>
> > > On Jul 29, 3:06 am, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > > On 28 Jul., 23:01, "Richard A. DeVenezia" <rdevene...(a)gmail.com>
> > > > wrote:
>
> > > > > On Jul 28, 12:42 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > > > > On Jul 28, 1:53 pm, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
> > > > > > > Is there no sashelp.v---- view for environment variables that gives a
> > > > > > > list of environment variable names and their contents? I can't see one
> > > > > > > among the list in sashelp. It's easy enough to write something for
> > > > > > > this but I was kind of expecting to find it in sashelp.
>
> > > > > > So I wrote a macro but when I run it on my laptop which has Windows 7
> > > > > > 64 bit on it with me having installed SAS/LE 4.1 in compatibility mode
> > > > > > I get the following. Forst the macro and then the message. Any ideas?
>
> > > > > Roland,
>
> > > > > Instead of using a macro and explicit filename and data steps, try
> > > > > creating a DATA Step view that creates the pipe, reads it, parses the
> > > > > name=value and outputs pertinent rows.
>
> > > > > ----------
> > > > > data sasuser.venv / view=sasuser.venv;
>
> > > > >   length _fref $8 _buffer $500;
>
> > > > >   rc = filename(_fref, 'SET', 'PIPE');
> > > > >   _fid = fopen (_fref, 'S');
>
> > > > >   do while (fread(_fid) = 0);
> > > > >     rc = fget(_fid, _buffer, 500);
> > > > >     _eq = index (_buffer, '=');
> > > > >     if _eq > 1 then do;
> > > > >       name = substr(_buffer,1,_eq-1);
> > > > >       value = substr (_buffer, _eq+1);
> > > > >       OUTPUT;
> > > > >     end;
> > > > >   end;
>
> > > > >   rc = filename(_fref);
>
> > > > >   drop rc _:;
> > > > > run;
>
> > > > > data _null_;
> > > > >   set sasuser.venv;
> > > > >   put name= @35 value=;
> > > > > run;
> > > > > ----------
>
> > > > > With proper credentials, you could install the view as SASHELP.VENV.
>
> > > > > Richard A. DeVeneziahttp://www.devenezia.com
>
> > > > Thanks for that but I am still wondering why it works on my machine at
> > > > work yet does not work on my Windows 7 laptop at home.- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > As with many PIPE related issues "what happens when you type SET in a
> > > dos box?"
>
> > > The google translation of the message "The handle is invalid validly"
> > > is interesting.- Zitierten Text ausblenden -
>
> > > - Zitierten Text anzeigen -
>
> > It works fine in the DOS box. It also works fine using an "x" command.
> > But it won't assign a file handle to it. The macro works fine using
> > SAS 9.2 on the Windows server at work which I think is XP
> > Professional. It just won't work on my 64 bit Windows 7 laptop running
> > SAS/LE 4.1 in compatibility mode.
>
> > "Das Handle ist ungültig" = "The handle is invalid". I guess it would
> > be "Invalid file handle" if it were an English version.
>
> > Perhaps it has got something to do sas trying to use the Windows 32
> > bit API.
>
> Did you try using the command string of "cmd /c set"? It might force
> SAS to open a new shell and get it to work.

I tried that. No good.