BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MattJans
Obsidian | Level 7

Not sure if this is a deployment issue, but didn't see a better group. Figured someone here would know. I'm having hard time finding anything online about how to do this. I can find info about SAS color coding in notepad++, but nothing about how to run SAS code from it.

Anyone know how or have leads? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

This is a popular topic, so I'm going to add a few details to help knowledge seekers.

 

Associate SAS files with Notepad++

You accomplish this in the usual way with Windows.  In Windows Explorer, right-click (or SHIFT+right-click depending on your setup) on a .SAS file (SAS program), and select Open with...

 

openwithnplus.png

 

You might see Notepad++ in the menu, but don't select it,  Instead, select Choose another app.

 

chooseapp.png

In this menu, select Notepad++ and check the "Always use this app" checkbox.

 

Repeat this step for SAS program logs (.LOG files) and listing output (.LST files) if you want.

 

Run a SAS program from Notepad++

You can add new program actions to the Run menu in Notepad++.  Here's how to add a command to run a SAS program, if you have SAS for Windows installed.  NOTE: This assumes that the SAS program is open in Notepad++ and is saved in a file.

 

  1. Select Run... from the Run menu.
  2. In the program to run field, enter this command:

    "C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin "$(FULL_CURRENT_PATH)" -log "$(CURRENT_DIRECTORY)\$(NAME_PART).log" -print "$(CURRENT_DIRECTORY)\$(NAME_PART).lst"


    all on one line.  You might need to adjust the SAS.EXE path for your install.  The command options use some Notepad++ environment variables to direct the SAS log and listing output to the same path as the SAS program file.

  3. Click Save (not Run)

    savecommand.png

  4. Optionally, assign a shortcut key to the action, and name it "Run program file in SAS" (or whatever you want).

This adds the command to your Run menu.  

 

runinsas.png

 

When you select it, Notepad++ will launch SAS, run your program in batch, and direct the output to the same folder where the program is stored.

 

Adding SAS syntax color coding to Notepad++

It's simple to "teach" Notepad++ to recognize the keywords from SAS and other languages. You can download new language definitions files from here -- follow the instructions on the page to have your Notepad++ recognize them.  Here's what SAS code looks like in my Notepad++:

 

notepad_sas.png

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

17 REPLIES 17
jakarman
Barite | Level 11

Notepad++ is great for editing and conversions the encoding recognition is one of the best. But it is not an IDE integrated development envirinment. That is Eguide.

You can edit sources and run them by a batch script or using the %include code for members in a directory using a filename.

---->-- ja karman --<-----
Duong
Obsidian | Level 7

Hi Matt

You can do something like this.

http://www.lexjansen.com/phuse/2011/pp/PP03.pdf

I prefer using Ultra Edit or Notepad++ too.

Duong

MattJans
Obsidian | Level 7

Doung, this is really helpful! Was as easy to setup as the article says. It's not one keystroke but that may be okay. I'll have to try it for a while. I like it b/c now I can split my SAS window just between the output and log, and keep my code separately (alt+tab is almost a reflect for me).

Here's somethings about the Keys window I didn't understand.

1) The article says to assign to Q or S. Q was already taken and S wasn't available. How do I add keys to the Keys window?

2) I had two available keys. First I tried ctrl+G. Nothing was assigned in Keys, but apparently that's assigned to "Go to Line". So what I put in Keys didn't change that. So I applied it to ctrl+J and it worked.

MattJans
Obsidian | Level 7

Correction...ctrl+G works as long as I'm not in the EE window (where it interprets that as go to line). ctrl+J works fine there.

Duong
Obsidian | Level 7

Hi Matt

S is available in Unix SAS but not PC SAS. For PC SAS I typically use Q. This is so that my index finger could reach A, C, Q while my thumb hold down the CTRL key.

But you could use any other available keys. 

Duong

jakarman
Barite | Level 11

If you want to see this is a deployment question you are correct.

The pré requis to have this functionality is having well implemented OS security layer controls. This can be a very hard political question when a server based installation is involved.

The bad thing SAS is doing is locking down their installation and ignoring this prerequisite.

---->-- ja karman --<-----
LinusH
Tourmaline | Level 20

Lets say that you can submit SAS code from your editor of choice. Then what? How would you access the result, log, output, data etc?

How does your SAS environment look like (DMS SAS, EG...?)

's tip doesn't offer much integration, it reduces four key-stroke combinations down  to three, so...

Since SAS is moving towards pure web clients I can't really see that they would prioritize integrating towards external fat Windows editors - the only logical place would be EG.

Data never sleeps
ballardw
Super User

Running code in batch or equivalent means you specify as part of your job where all desired output goes. There will be default locations but depending on OS and setup may be difficult to find.

When I was using OS/2 I much preferred the IBM Enhanced program editor but was able to add menu items to editor to run SAS for that script with different options such as passing the location of the script file as the default output location.

Duong
Obsidian | Level 7

My response was under the assumption that Matt wants to submit SAS codes interactively but

preferred to use a non-SAS editor.

If you don't have Eguide and you are using Unix SAS the DMS editor is not great so you

might want to use this gsubmit technique. 

In response to Linus - I am not sure if you had read the paper carefully. Instead of the SAS

DMS editor panel you use UEdit in its place. The SAS environment will still be the exactly same. That is the

log/output will still go to DMS log/output. You will not lose any SAS functionality but have an option

to choose an alternative editor.

And if you are still on SAS DMS you might want to try this with gsubmit.

http://www.lexjansen.com/phuse/2011/pp/PP02.pdf

Duong

MattJans
Obsidian | Level 7

Thanks all for the tips and great leads! I haven't tested it out yet, so I'll leave it as "unanswered". A little more about my user situation in case there's any more advice...

1) I work with SAS on two computers at work and one at home, so it's important to me to find a solution that doesn't require me to setup customization on each installation and is easy to reconfigure when SAS is re-installed. It seems like I can set up code display preferences in Notepad++ and then copy that preferences file from machine to machine pretty easily. In addition, my work PCs are locked down so I can't install Emacs or anything like that. I looked into it, but then decided I didn't want to have completely different programming environments at home and work (most programming is done at work anyway).

2) I'm trying to move to Notepad++ for all my coding (first) and then all my writing. I realize it's not an IDE, but it has a lot of what I really like (i.e., autofill text, active line highlighting, block select, parentheses checks, great find feature). I'm almost completely out of Textpad now that I've found it.

3) I usually run my SAS from the Enhanced Editor. I write fairly short and compact programs so I can just hit F3, but in development I tend to highlight and F3. I just learned about batch submit (or rather was reminded and decided I should switch, but haven't spent the time to figure out how exactly to do it...I don't program everyday)

4) I work in Stata at least as much as SAS (more lately) and in R. This is another reason why having a single editing environment is appealing. All generic editor KB shortcuts and macros and ones I program can be in one place, programmed once, and the same no matter what I'm coding in.

Re: the Enterprise Guide, I tried it once during a SAS class, but it was just too different (and a little buggy...or what seemed to me as buggy because it was new). I liked the auto-completion, but the overall interface was just too different for me to handle during a class, and I haven't gone back yet. What would folks consider to be the biggest benefits of EG over coding in a separate text editor and submitting via batch? I really liked what it seemed to offer and is probably good for getting more people into SAS. How would an intermediate researcher/programmer who doesn't code everyday benefit from it?

Thanks again!

jakarman
Barite | Level 11

Eguide has a lot of advance to just a source text editor.

Auto complete, analyze program, log analyze are nice when your world is still an editor approach. This the basic way of 30 years ago. The real difference is on other areas,  as there are:

- flow execution of your programs

- support for parrallel processing

- coding by example clicking tasks

- some integration with Microsoft is it is .net application

- metadata based options

- server bases processing with a server optimized for doing real analytics work.

As you are having a locked sas environment you IT support is not trusting you processing you the data or having issues to define os controls. With Stata and R you are needing those os controls when processing sensitive data.

You are a nice example of having a crippled sas system to be in competition with not crippled other approaches or there is something wrong with alignment with IT.

---->-- ja karman --<-----
LaurentdeWalick
Fluorite | Level 6

Did you have a look at the NppExec plugin for Notepad++? I haven't tried it myself, but it enables starting an external program and sent the code to it.

You might find more help on Notepad++ over at Stack Overflow: http://stackoverflow.com/tags/nppexec

http://superuser.com/questions/176678/how-to-launch-a-program-from-notepad

MattJans
Obsidian | Level 7

Thanks for all the great advice! I'm going to call this closed for now. I didn't achieve my stated goal, but I haven't had a lot of time to put into it. I learned how to submit commands via batch and do color coding in Notepad++. But for now, I need to stop tweaking my setup and get back to work Smiley Happy

Thanks again.

ChrisHemedinger
Community Manager

This is a popular topic, so I'm going to add a few details to help knowledge seekers.

 

Associate SAS files with Notepad++

You accomplish this in the usual way with Windows.  In Windows Explorer, right-click (or SHIFT+right-click depending on your setup) on a .SAS file (SAS program), and select Open with...

 

openwithnplus.png

 

You might see Notepad++ in the menu, but don't select it,  Instead, select Choose another app.

 

chooseapp.png

In this menu, select Notepad++ and check the "Always use this app" checkbox.

 

Repeat this step for SAS program logs (.LOG files) and listing output (.LST files) if you want.

 

Run a SAS program from Notepad++

You can add new program actions to the Run menu in Notepad++.  Here's how to add a command to run a SAS program, if you have SAS for Windows installed.  NOTE: This assumes that the SAS program is open in Notepad++ and is saved in a file.

 

  1. Select Run... from the Run menu.
  2. In the program to run field, enter this command:

    "C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin "$(FULL_CURRENT_PATH)" -log "$(CURRENT_DIRECTORY)\$(NAME_PART).log" -print "$(CURRENT_DIRECTORY)\$(NAME_PART).lst"


    all on one line.  You might need to adjust the SAS.EXE path for your install.  The command options use some Notepad++ environment variables to direct the SAS log and listing output to the same path as the SAS program file.

  3. Click Save (not Run)

    savecommand.png

  4. Optionally, assign a shortcut key to the action, and name it "Run program file in SAS" (or whatever you want).

This adds the command to your Run menu.  

 

runinsas.png

 

When you select it, Notepad++ will launch SAS, run your program in batch, and direct the output to the same folder where the program is stored.

 

Adding SAS syntax color coding to Notepad++

It's simple to "teach" Notepad++ to recognize the keywords from SAS and other languages. You can download new language definitions files from here -- follow the instructions on the page to have your Notepad++ recognize them.  Here's what SAS code looks like in my Notepad++:

 

notepad_sas.png

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 17 replies
  • 63605 views
  • 39 likes
  • 9 in conversation