BookmarkSubscribeRSS Feed
DanielRingqvist
SAS Employee

REGION isn’t actually a statement but a comment. When you start a comment with region, SAS Studio recognizes it and treats the following lines – up to a comment marked /* endregion */ - as a collapsible block of code. This feature works in VS Code as well. It’s a practical way to group together data steps and procedures, allowing you to submit all the code in one go (Run Region) without having to manually select large sections. Regions can also be nested, as shown in the demo and example code. In SAS Studio, these regions are collapsible also in the SAS Log, making code management even easier. For a demonstration, see the video. You can find the code further down. 

 

 

/* region main */

/* region connect to data */
libname xl XLSX "%sysget(HOME)/data/CARS.xlsx";
/* endregion */

/* region Fetch data */
proc sql noprint;
    create table WORK.CARS_Europe_raw as 
    select * from XL.cars
    where Origin='Europe';
quit;
proc sql noprint;
    create table WORK.CARS_Asia_raw as 
    select * from XL.cars
    where Origin='Asia';
quit;
/* endregion */

/* region Cleanse and enrich  */
data WORK.CARS_Europe;
    set WORK.CARS_Europe_raw;
    L10kmCity = 23.521 / 'MPG (City)'n;
    L10kmHighway = 23.521 / 'MPG (Highway)'n;
run;

data WORK.CARS_Asia;
    set WORK.CARS_Asia_raw;
    L10kmCity = 23.521 / 'MPG (City)'n;
    L10kmHighway = 23.521 / 'MPG (Highway)'n;
run;
/* endregion */

*Clean up...;
proc datasets lib=WORK nodetails nolist ;
    delete CARS_Asia_raw CARS_Europe_raw;
run;

/* endregion all steps */
2 REPLIES 2
pchegoor1
Obsidian | Level 7

@DanielRingqvist   Does this Work on SAS Studio Release: 3.82 (Enterprise Edition)  which comes with SAS 9.4M8?

 

I tried but it does not seem to working.

DanielRingqvist
SAS Employee
It does not as far as I am aware. As you're on SAS9, have you tried VS Code with the SAS Extension? It's supported in the same way (not in the LOG however.) Brilliant UI against your local or remote SAS9 and so easy to get started.