Your Ad Here

Posted By

webonomic on 03/31/08


Tagged


Versions (?)

Get Computer Name


 / Published in: SAS
 

URL: http://jaredprins.squarespace.com/blog/2008/3/31/sas-get-computer-name.html

This code will help you to get the name of the computer you are running he code from.

  1. /*Method 1*/
  2. %let cname = “%sysget(computername)”;
  3.  
  4. /*Method 2*/
  5. filename getinfo PIPE “hostname” ;
  6. data _null_ ;
  7. infile getinfo ;
  8. input ;
  9. put _infile_ ;
  10. run ;
  11.  
  12. /*this works because 'hostname' is a command whereas trying to use 'computername' will not work because it is a system variable*/
  13.  
  14. /*Method 3*/
  15. filename getcmd pipe ‘net config workstation’;
  16. data theds(keep=theline);
  17. length theline $200;
  18. infile getcmd length=lenvar;
  19. input @1 theline $varying. lenvar;
  20. run;
  21. /*then parse out pieces you want*/
  22.  
  23. /*Method 4*/
  24. %Put computername<%sysget(computername)>;
  25. /*again, parse out what you need*/
  26.  
  27. /*All of the above ones may work on Unix/Linux with the exception of Method 4*/

Report this snippet  

You need to login to post a comment.