Using Notepad++ as your SAS code editor


News flash: My favorite SAS code editor is SAS Enterprise Guide. However, my favorite general purpose text editor is Notepad++, and I often find myself using that tool for viewing SAS log files and for making small modifications to SAS programs. Judging from the popularity of this SAS Support Communities discussion, I'm not alone. In this post, I'll share the steps for turning Notepad++ into a more useful home for SAS programs.

You can download Notepad++ for Windows from here -- you can use it for free, no cost. That's one reason that it's one of the first tools that I install on any new PC I get my hands on!

1. 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...

Open with menu

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

Choose another app

► 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.

2. 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: These steps assume that the SAS program is open in Notepad++ and is saved in a file.

► Select Run... from the Run menu. 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.

Click Save (not Run).

Click Save

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.

Run in SAS command

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.

3. 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. I've created an expanded definition file that includes more SAS keywords (many, many more!) -- you can grab that from my GitHub repo here (be sure to copy/save the "raw" view of the file as XML, then import that into Notepad++).

Note: some people have reporting problems trying to import the file I shared. Here's one comment with a workaround: "The SAS XML langage script for NPP (implicitly : NPP running on Windows) you generously provide must be transcoded into ANSI before import, downloading the GitHub file with a browser, even the raw version, gives you the XML file encoded with UTF-8, which fails to import, at least for me. For this transcoding, I only had to open the file, with NPP itself then select Encoding / Convert to ANSI, then Ctrl+S."

Here's what SAS code looks like in my Notepad++:

code sample in Notepad++

What else?

I'm sure that some of you have spent more time than I have in creating a souped-up Notepad++ environment, or perhaps you've taken it to another level with other popular editors like Sublime or Vim or UltraEdit. If you have other tips to share, I'd love to hear from you in the comments.


About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies


  1. Your language definition fails to import in Notepad++ v7.4.2

    Please update it, I'd be very interested in trying it out, seems more comprehensive than the other ones I've found online so far.

    • Chris Hemedinger
      Chris Hemedinger on

      Hi Alex, I tried this from my home PC (v6.9, which I then updated to v7.4.2) and I was able to import the file with no problems. I re-exported from v7.4.2 -- the file was identical to what I shared on my GitHub.

  2. Richard Thomas on

    I was unable to import into Notepad++ 7.4.2 as well. I tried the manual process (copy to install folder, rename to userDefineLang.xml), but it's not being picked up.

    • Chris Hemedinger
      Chris Hemedinger on

      I've tried this on a few "clean" installs now, and had no problems. I download the UDL file as a local XML (be sure to navigate to "Raw" view first!), then in Notepad++ I go to Language->Define your language. In the big User Defined Language window, I select Import..., then select the XML file I just downloaded. That adds a SAS option the list of "User languages" at the top. When I select "SAS", there are my rules!

  3. Chris,

    I successfully imported your UDL from GitHub into my Notepad 7.4.2. I didn't have any import issues. (For a few years, I was using another SAS UDL, and I replaced it with yours.)

    I also often use Notepad++ in general and sometimes with SAS. I wish Notepad++ would allow running snippets of code and browsing SAS data sets, and I wish the base SAS Enhanced Editor for Windows would notify the user when the source code changes. This feature facilitates switching back and forth between editors.

    • Chris Hemedinger
      Chris Hemedinger on

      Thanks for letting me know! And actually, SAS EG v7.13 supports that last one: it detects when the SAS file has changed and notifies you, and asks you whether you want to reload the file.

    • You might want to take s look at UltraEdit. It is very SAS-friendly and handles your wishes. I've used it for more than 15 years, but I haven't been able to use it for running SAS for a couple years, but I had used it heavily to code and submit jobs to a UNIX machine through its built in FTP feature. It also can poll the.log and .lst files and automatically update the displayed log and output information.

      I've not used Notepad++, but I strive to get UE installed on any system I use. As a contractor, I sometimes have to justify the expense, but that hasn't been a major issue.

  4. shawn skillman on

    This works like a champ, thank you for sharing. I have been a fan of Notepad++ for a while but never explored running SAS code from the editor.

  5. The file import didn't work for me, but as a work around, I was able to get it to work by copying the lines from the RAW view into the userDefineLang.xml file.

    • Chris Hemedinger
      Chris Hemedinger on

      Glad that works -- still at a loss about the import process. I'll look into it. I've heard from others that it worked fine.

  6. Thanks Chris, this is very useful :).

    The SAS XML langage script for NPP (implicitly : NPP running on Windows) you generously provide must be transcoded into ANSI before import,
    downloading the GitHub file with a browser, even the raw version, gives you the XML file encoded with UTF-8, which fails to import, at least for me..
    For this transcoding, I only had to open the file, with NPP itself (v 7.3.3) then select Encoding / Convert to ANSI, then Ctrl+S.

    Notepadd++ is great for editing or even only reading SAS scripts stored locally on Windows or even remotely on Unix/Linux
    when it's also defined as the default script editor for your SFTP client (WinSCP, Filezilla, MobaXterm etc.). I've used it for years.

  7. Thanks, Chris! I ran into problems at step 2. I suspect that Notepad++ cuts off the Run-string after 256 characters. When I shortened it to below 256, cutting "unnecessary" SAS command line options, it worked like a charm.

    • Chris Hemedinger
      Chris Hemedinger on

      Good to know! I suppose you could wrap the elements of this command in a BAT or CMD script to shorten the string for Notepad++.

  8. I think I worked out what is happened with it failing. If you right click on the file and save it what you get is something different to what is expected. You first need to click on the link then change it to raw then save it. Not exactly obvious.

  9. very nice tip :-)
    Beside Enterprise Guide i use Notepad++ for years and was using an other SAS syntax file which also included some small problems. Your syntax file seems to be better!
    I would suggest one small addition: add the %macro and %mend Keywords to the code folding definition. Folding macros in huge programs can be a large time saver.
    Keep up the good work Chris!

    • Chris Hemedinger
      Chris Hemedinger on

      Good suggestion on the code folding -- I think I tried that for a bit, but found a few places where it seemed to break down. However, the extra convenience might be worth the few exceptions...

  10. Thank you SO MUCH for doing this! I've been feeling a little nutty from the buggy mouse behavior in the Studio 3.6 editor, and downloaded this to write & edit code in peace (with nothing but my own mistakes to annoy me).

  11. This is great stuff Chris! Thanks!!!
    No issues whatsoever with the import.
    Would you be able to tell me I'd be able to "remote submit" through notepad++
    and/or even running snippets interactively (remote and local), or is that pushing it? :-D.

    • Chris Hemedinger
      Chris Hemedinger on

      It's definitely possible...but it requires writing an external program or script that accepts the file name, reads the file contents, connects to a remote SAS session (using SAS Integration Technologies), submits the code, and fetches the results.

      I don't have an example of exactly this, but on my blog you'll find a number of Windows PowerShell and Microsoft .NET examples that could be the starting point for something.

  12. Hello Chris,

    I was referred to this thread regarding an updated Notepad++ SAS style from a link in Larry LaRusso's SAS Tech Report.

    Others in this thread have reported problems with the .xml definition import, and my initial experience was the same. When I tried saving the RAW contents of the .xml from Github to disk, the import failed and almost immediately my computer experienced some kind of 'command key stuck in down position' effect.

    Having used Notepad++ with an earlier SAS style, I tried exploring whether there was something in the syntax that was the issue, but I think it may related to the file encoding. Github might have a unix prepared copy of the contents which are exporting in my case as a UTF-8 with BOM.

    I used Notepad++ to convert the encoding to UTF-8 (without BOM). Once the .xml style file was saved in a more Windows friendly encoding, there were no issues with importing.

    Maybe something to mention for other users who encountered the same.

  13. Hi Chris,

    Thank's for sharing -
    I try to import the code in notepad++ v.7.5.6.
    Unfortunately, it doesn't work. Do you have an explanation ?

    Have a nice day

  14. Pingback: Ten SAS Enterprise Guide program editor tricks - The SAS Dummy

  15. Before I used the import functionality, I converted some tags, for example "&" to "&", "<" to "", etc. It worked.

  16. I have tried everything as mentioned in this post for using NOTEPAD ++ as SAS editor. Everything went good. I really don't know where WORK datasets will get stored after its creation from the SAS program run on NOTEPAD++

    • Chris Hemedinger
      Chris Hemedinger on

      By default, the WORK location will be in your TEMP area, and deleted when the SAS session ends. If you want to change that, add the -WORK option to the SAS command with an alternate location.

      • Yes. I could see when we run SAS program from outside editor , it open and closes the SAS session upon completion of the program. So there is no chance to browse work datasets as we do in SAS editor. I understood now. Thanks for your prompt reply.

      • Hi Chris,

        When I run from within NotePad++, how come I don't see the log? I also can't see the work library to browse... It appears it opens SAS, runs, then closes SAS?

        • Chris Hemedinger
          Chris Hemedinger on

          Hi Ricky, running in Notepad++ is a convenience, but not a replacement for a full IDE. Notepad++ does allow you to add some custom actions, so opening the log file (given that the script uses a predictable name convention) should be possible.

  17. Hi Chris.

    Thanks for the language file for NPP. I have been struggling with it for the last couple of days for the Code folding to work correctly but it was giving very weird results. When I created a new file and write code, the folding was fine as I type. Once I save the file and reopen it, alI code folding was messed up and there was no way I could fix it.

    I finally figured out what was going on. I had my default for New File set to Unix. So, as I was typing in a new file, I think it was still applying Windows CR/LF. Only when I saved the file, it converted CR/LF to Unix EOL. If I change EOL back to Windows on the reopened file, the code folding works fine again.

    I have looked into all the options available in the User Defined Language but can't find anything that could make it work in Unix files.

    Any suggestions you have to work around this.

    Thanks in advance for your help.

  18. Ramesh Kumar SK on

    Thanks! It works fine expect for the coloring in the below PROC SQL statement with macro variables.

    proc sql;
    create table &m_inlib..test1 as
    select *,
    from &m_InDSN(DROP=&rndprmvarlist.);

    Anything after the double quotes (") in the %sysfunc statement is not color coded. Any suggestions or workaround would be helpful.


  19. @Ramesh - specifying an "Escape:" char for the double-quote delimiter should suffice, but it does not work for me.

    Also related to quoted strings, double-quoted strings that continue onto a second line are not interpreted correctly for me. For example:

    *--- The following code requires moderate explanation
    that continues onto a second line - But this line is no longer comment-highlighted ;

    I think that these issues are more likely with NPP UDL 2.0 facility (my version:, which remains a bit buggy for our purposes.

    • UPDATE:
      Intended example of double-quoted string, in code, or in comments, not highlighting correctly:

      *--- The following code requires moderate explanation, including "A quote
      from a renowned source" that continues onto multiple lines -
      But this line is no longer comment-highlighted and looks like an continuing quoted-string ;

      Comments about buggy NPP UDL 2.0 still apply.

  20. Regular expression are really a language on his own inside SAS. The best a can suggest in Notepad++ UDL2 config for SAS is :
    Define a new "Delimiter n style"
    Open: (s/
    Close: ,

    This will limit coloring syntax problem until the next comma. Important note no space allowed after the "(" character.

    I've made a "Regular Expression Patch" edition of UDL2 here :

    Hope this will help.

  21. I cannot download the sas language highlighting for notepad++ in the abovementioned link "You can download new language definitions files from here -- ". Any solution? I appreciate it!

  22. Today i've finally figured out a nice Notepad++ ULD2 workaround for SAS multi-lines comment «*», «%*» and «comment» highlighting.

    I've been working on this for many months before finding a really effective workaround.

    The problem was that SAS multi-lines comment «*», «%*» and «comment» behave "like" a single line comment for Notepad++.
    They open at the start of a line only and preceding whitespaces are allowed.

    You can read the complete explanation for the solution in the README.TXT file under the "Files" tab here :

    In short allow any ASCII characters to be a continue character.
    But Notepad++ don't allow the "SPACE" and "TAB" characters to be continue characters. We have a bit mote than 99% effective workaround.
    Remove all whitespaces at the end of each comment lines and this workaround will be fully effective.

    Hope this will give better comment highlighting and comment folding for your SAS source code with Notepad++.

  23. Alexandros BITOULAS on

    Many thanks for this very useful work! It works straight away after saving the file from the Raw view of the file on Github (otherwise simple download did not work).

  24. Just like #2 Run a SAS program from Notepad++ (which is for Windows), Within Notepad++, Is there anyway I can run SAS code via connecting to Linux SAS server script ?

  25. John Iwaniszek on

    I would like to change the default line comment inserted from the context menu (and ctrl-q) from * to %*. I did it once before but I can't seem to recreate my search to find out how. Can you help? I am using the UDL SAS_default_color_syntax_XML_Hack_LF_TAB.xml

Leave A Reply

Back to Top