DATA Step, Macro, Functions and more

SAS 9.4 Tab Shortcut

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

SAS 9.4 Tab Shortcut

[ Edited ]

Hello all!

 

Is there a way to tab a selected block of code?

 

For Example, I want this:

 

Data temp;

do i =1 to 10;

if i=2;then j=5;
else if i =3 then j=1;
else j=3;

end;run;

to be this in one keyboard command after selecting the code:

 

Data temp;

do i =1 to 10;

     if i=2;then j=5;
     else if i =3 then j=1;
     else j=3;

end;run;

Thank you! And sorry if this question has already been posted. And if you know the answer, can you also tell me how to go backwards?

-Victor


Accepted Solutions
Solution
‎12-20-2016 03:23 PM
Super User
Posts: 10,454

Re: SAS 9.4 Tab Shortcut

Are you asking about indenting the code or storing it for later recall?

 

I would expect that if you highlight to select lines and then press the tabl key it should indent.

 

And what do you mean by "go backwards?" If you mean to reverse indent then select lines and use shift+tab keys.

View solution in original post


All Replies
Solution
‎12-20-2016 03:23 PM
Super User
Posts: 10,454

Re: SAS 9.4 Tab Shortcut

Are you asking about indenting the code or storing it for later recall?

 

I would expect that if you highlight to select lines and then press the tabl key it should indent.

 

And what do you mean by "go backwards?" If you mean to reverse indent then select lines and use shift+tab keys.

Contributor
Posts: 24

Re: SAS 9.4 Tab Shortcut

Thank you so much! Yes, just simply indenting the code. Sorry, the answer was so obvious.

 

How would you store the code for later recall though?

Super User
Posts: 10,454

Re: SAS 9.4 Tab Shortcut

Storing code would depend on which way you are using SAS, base, Enterprise Guide or Studio.

In base SAS you can store "abbreviations". From the Editor select the text, go to the Tools menu and select Add Abbreviation. Enter a name for the abbreviation in the top box and then paste the code into the box labeled Text to insert for abbreviation. The "name" typed into the box becomes a prompt that when typed allows you to accept the abbreviation into the editor. So it makes sense to use an uncommon combination of keys to start the "name". I use things like #t. I recommend not using % or & due to use in macros.

You can also generate keyboard macro code to instert characters (which ends up much like the abbreviation in execution).

 

SAS Studio uses "snippets" but I don't use Studio so I can't supply details.

Contributor
Posts: 24

Re: SAS 9.4 Tab Shortcut

THIS IS AWESOME!!

 

Thank you so much. The abbreviations will be incredibily helpful and fun. What do you mean by generate keyboard macro code to insert characters though? Can you provide a small example for me?

Super User
Posts: 10,454

Re: SAS 9.4 Tab Shortcut

I suggest using the menues avaiable from Tools -> Keyboard Macros  and experimenting.

You can record a series of operations, you can do a large number of things in the editor related to searching, selection, insertion, code formatting (make sure you don't do this with a critical code file without making a copy. You only have to sort a code file once to find out that order is very hard to recover if not careful).

 

Some actions make more sense for selected (highlighted code), such as the mentioned sort, some navigate through the file, some do things with line markers that are not part of the file.

Contributor
Posts: 24

Re: SAS 9.4 Tab Shortcut

Sounds good! That gives me a idea of what keyboard macros can do!
Trusted Advisor
Posts: 1,349

Re: SAS 9.4 Tab Shortcut

The tool to ident a group of lines depends on the SAS environment.

 

Assuming you are not working on MF, try to select the wanted lines by the left mouse button

and then click on TAB to indent th elines to the right, or click Shift-TAB to indent to the left.

Contributor
Posts: 24

Re: SAS 9.4 Tab Shortcut

Thanks for the response!
☑ This topic is SOLVED.

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

Discussion stats
  • 8 replies
  • 349 views
  • 4 likes
  • 3 in conversation