SAS OnDemand for Academics

SAS OnDemand for Academics or SAS ODA is a SAS EG cloud application free of charge. You install SAS EG on your local machine and the data is in the cloud. You get 5Gb of data. You can store programs on your local PC. It has one drawback, you cannot create library reference that points to your local drive. You can however import, export data to your local drive.

I ran into the issue that I had to install the SAS practice data in the cloud which I had installed in SAS Studio on my local PC. Next describes a solution.

  1. Open SAS ODA
  2. Go to File -> Open -> Data
  3. Navigate to your local PC directory where you have stored the datasets. Select them all and press open. (Only select the datasets, not the views).
  4. All the selected datasets will appear in the Project Tree Window under Process Flow node.
  5. Go to the Process Flow node and select all the tables. Then press right mouse click and select Query Builder.
  6. This may take a long time so be patient. What SAS is doing is creating temp tables in the WORK area and constructing the query builder for you. Wait when everything is responsive again and skip the query builder. We were only using it to get the tables in the work area.
  7. Go to the Servers Window and create a permanent directory. I created it under Servers -> SASApp -> Home -> sasuser.v94 -> certprep. In my case the libref is this one:
    LIBNAME CERTPREP "/home/<youraccount>/sasuser.v94/certprep"
  8. Then copy the data from WORK to CERTPREP using code below. It gives two methods using the same technique. Anyway, the practice data is now in the cloud, in a permanent library.
LIBNAME CERTPREP "/home/<youraccount>/sasuser.v94/certprep";
data _D1_ (keep=memname);
  set sashelp.vtable;
  if libname eq 'WORK' and index(memname,'_') ne 1;          /* skip _ prefixed datasets */
run;

data _D2_;
  set _D1_ end=lastobs;
  sd=catt("work.",memname);                                  /* source dataset */
  td=catt("certprep.",substr(memname,1,length(memname)-4));  /* target dataset */
  call symputx(catt("mvSource",_N_),sd);                     /* one macro variable per source dataset */
  call symputx(catt("mvTarget",_N_),td);                     /* one macro variable per target dataset */
  if lastobs eq 1 then call symputx("mvCount",_N_);          /* the count of datasets */
run;

%macro _M1_; /* Copy the datasets */
  %do i = 1 %to &mvCount;
    data &&&mvTarget&i;;
      set &&&mvSource&i;;
    run;
  %end;
%mend _M1_;
%_M1_

%macro _C1_; /* Clean up the macro variables */
  %do i = 1 %to &mvCount;
    %symdel mvTarget&i /nowarn;
    %symdel mvSource&i /nowarn;
  %end;
  %symdel mvCount /nowarn;
%mend _C1_;
%_C1_

%macro _M2_; /* All in one macro */
  LIBNAME CERTPREP "/home/<youraccount>/sasuser.v94/certprep";
  data _null_;
    retain ptr;
    set sashelp.vtable end=lastobs;
    if libname eq 'WORK' and index(memname,'_') ne 1 then do;                                   /* skip _ prefixed datasets */
      ptr+1;
      call symputx(catt("mvSource",ptr),catt("work.",memname));                                 /* macro variable per source dataset */
      call symputx(catt("mvTarget",ptr),catt("certprep.",substr(memname,1,length(memname)-4))); /* macro variable per target dataset */
    end;
    if lastobs eq 1 then call symputx("mvCount",ptr);                                           /* the count of datasets */
  run;
  %do i = 1 %to &mvCount;
    data &&&mvTarget&i;;
      set &&&mvSource&i;;
    run;
    %symdel mvTarget&i /nowarn; /* clean up of macro variable */
    %symdel mvSource&i /nowarn;
  %end;
  %symdel mvCount /nowarn;
%mend _M2_;
%_M2_