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
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.
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.
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?
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.
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?
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.
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.