Help using Base SAS procedures

Emacs ESS: How to write a SAS program on Emacs?

Accepted Solution Solved
Reply
Contributor
Posts: 72
Accepted Solution

Emacs ESS: How to write a SAS program on Emacs?

Hi everyone,

I've started learning Emacs today so that I will be able to write SAS programs and run them from within Emacs, rather than directly on SAS. I've downloaded and installed Emacs from this site:

http://ess.r-project.org/index.php?Section=home

Everyone got through as expected.

However, I really don't know how to type in a piece of codes once I've entered Emacs. I've searched through online resources, and I've seen guides, tutorials, etc.. on Emacs, but most of them are on things like how to delete a whole word, delete one character back, etc... Basically, the resources are comprehense and useful for users, but for a complete newbie like me, the first thing is to write a piece of codes and I just can't find where it shows how to do such a thing.

When I type in a tiny SAS programs, the cursor just jumps randomly across the screen. I don't know how to do it.

Could you please help?


Accepted Solutions
Solution
‎02-09-2012 12:11 AM
Contributor
Posts: 72

Re: Emacs ESS: How to write a SAS program on Emacs?

Hi FriedEgg, thanks for help.

1) I am using Windows 7 on my PC

2) I can connect to a Unix server through SSH with either PuTTY or SSH

BUT

3) I installed GNU Emacs from http://ess.r-project.org/index.php?Section=home . It's called Emacs Speaks Statistics (ESS). I simply clicked on the icon on my Windows 7 desktop, and Emacs open

4) YES, my problem is after I click on the Emacs desktop icon, Emacs open but this is the first time I come to Emacs, so I don't know how to start a new file, type SAS programs in it, save it, and run SAS on it. That is my problem!

How can I get all the syntax highlighting and coloring in Emacs for SAS? I did as you said and I am now able to write a SAS program in ESS, but I can't figure out how to run such a SAS program within Emacs. After writing the SAS program, save it and close it, is it possible to run SAS directly within Emacs or I must leave Emacs and upload the file to Unix server and run SAS up there?

Thanks so much

View solution in original post


All Replies
Trusted Advisor
Posts: 2,113

Emacs ESS: How to write a SAS program on Emacs?

I've never bothered to install ESS on my Windows version of EMACS, but I do use it on the Unix environment.  The first thing to know about ESS is that it operates based on the file extension of the program, so your SAS program needs to have an extension of .sas .

All ESS does is to add some pretty formatting and color highlighting for SAS keywords; you still have to know the syntax that you want to use.   Because I have programmed in SAS for so long, I have my own style and it is more work to modify ESS than to ignore it.  ESS is not nearly as contextually smart as the SAS editor in Enterprise Guide, but it is more flexible for editing.

As far as the cursor jumping across the page, that is not typical behavior.  It could be a problem with ESS and it could be a problem with EMACS.  To test, create a new file with the .txt extension and edit that.  If the cursor still jumps it is likely a problem with your installation of EMACS.  Your best bet may be to uninstall both and then install EMACS anew and test it.  If it works, you could try then to additionally install ESS and see if that works.

Doc Muhlbaier

Duke

Contributor
Posts: 72

Emacs ESS: How to write a SAS program on Emacs?

Thank, Doc@Duke.

What I am asking is how to write something in Emacs, not how to run SAS from within Emacs. I used Unix on Windows via SSH, and I ran the batch job there. I often write a SAS program in SAS, then upload the file via SSH and then run it as a background job.

However, I now want not to write a SAS program using Notepad++ or SAS Program Editor. I want to write a SAS program straight within Emacs. I opened Emacs but I cannot type in something. Suppose I want to write sth like this

data output;

set input;

if n ^= 100;

run;

I cannot type those lines in Emacs. HOw can I open a new file in Emacs and start typing those lines above, then save, exit, and how can I run SAS while I am still in Emacs. People tell me they can do everything within Emacs as far as SAS goes, like editing/writing a new SAS program, editting it, then running it without openning the usual SAS outside of Emacs.

Thank you

Trusted Advisor
Posts: 2,113

Emacs ESS: How to write a SAS program on Emacs?

You can do those things (at least I do in the Unix environment).  The fact that you can't type anything into EMACS says that there is something wrong with your installation of EMACS. 

Super User
Super User
Posts: 6,497

Re: Emacs ESS: How to write a SAS program on Emacs?

I think the easist way to open a new file with Emacs is to give it the name on the command line.

For example if I type "emacs newfile.sas" and newfile.sas does not exist then I get an empty screen and I can start typing the code.

Trusted Advisor
Posts: 1,300

Re: Emacs ESS: How to write a SAS program on Emacs?

Trying to understand the problem, please verfiy the following assumptions:

1) You are using Windows on your personal machine you are physically interacting with

2) You are using said Windows machine to connect to a Unix server through ssh,  I assume you are opening a terminal session there with an application like PuTTY from Windows.

3) On the unix machine you are trying to open emacs on the unix machine and write a piece of code and save it locally to that machine so that you can manually execute the job as a batch service at some point later.

4) Your problem is that after you open emacs you find yourself unable to type anything?

Emacs is a very nice utility with an ungodly amount of features and functions.  It is not however the most user friendly piece of software and one must now how to navigate the software in order to use it.  It uses a vast assortment of key sequences and or combinations typed into it's itegrated command line in order to function.  Have you read the software documentation in order to understand how to interact and use Emacs?  If you are only trying to use Emacs becuase you want to use a text editor in Unix that will provide you with syntax highlighting there are plenty of other options to consider that are more user friendly.

To launch Emacs and start typing a piece of code you can do the following:

open the application:

$>emacs

HIT F10 to open the menu system, HIT F to open the file menu, HIT N to open a new buffer window

Type your program

HIT F10 to open the menu systen, HIT F to open the file menu, HIT S to perform a Save Buffer As...

Solution
‎02-09-2012 12:11 AM
Contributor
Posts: 72

Re: Emacs ESS: How to write a SAS program on Emacs?

Hi FriedEgg, thanks for help.

1) I am using Windows 7 on my PC

2) I can connect to a Unix server through SSH with either PuTTY or SSH

BUT

3) I installed GNU Emacs from http://ess.r-project.org/index.php?Section=home . It's called Emacs Speaks Statistics (ESS). I simply clicked on the icon on my Windows 7 desktop, and Emacs open

4) YES, my problem is after I click on the Emacs desktop icon, Emacs open but this is the first time I come to Emacs, so I don't know how to start a new file, type SAS programs in it, save it, and run SAS on it. That is my problem!

How can I get all the syntax highlighting and coloring in Emacs for SAS? I did as you said and I am now able to write a SAS program in ESS, but I can't figure out how to run such a SAS program within Emacs. After writing the SAS program, save it and close it, is it possible to run SAS directly within Emacs or I must leave Emacs and upload the file to Unix server and run SAS up there?

Thanks so much

Super User
Super User
Posts: 6,497

Re: Emacs ESS: How to write a SAS program on Emacs?

It sounds like you are running Emacs on your PC, but you are running SAS on your Unix server.  So you will probably need to modify some of the lisp code that makes ESS work.

To do this you need to figure out what steps you need take to move a file from your PC to the Unix box and run SAS on it.  Probably also how to make the SAS log and listing available to your PC.

If you are lucky the Unix and PC machines can access the same files (although the pathnames will be different) and the only thing you will need to change is the steps needed to run SAS.

☑ This topic is SOLVED.

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

Discussion stats
  • 7 replies
  • 5057 views
  • 0 likes
  • 4 in conversation