Tag Archives: SAS language

From Non-SAS Programmer to SAS Programmer Part II

Previously, we wrote about how you can become a SAS Programmer with little or no programming background.

Today, I want to share a new link where you can download SAS Studio for free and practice. I have to give a thank to Andrew from statskom for the tip. Visit his blog for more SAS tips.

Here is a quick step on what you need in order to use the SAS University version for free provided by SAS:

1- Create a SAS profile and select the environment based on your operating system in order to download the SAS® University Edition. I  chose Oracle VirtualBox. The options available are: Oracle VirtualBox in Windows, Macintosh, and Linux operating environments.

2- You will receive an email where you can you download your SAS edition as per your selected environment on step 1. Click the link. It could take up to an hour for the entire program to download.

SAS University Edition

3-Go to https://www.virtualbox.org/wiki/Downloads to install the OracleVirtualBox.

4-Add the SAS University Edition vApp downloaded on step 2 to VirtualBox step 3.


5-Create a folder for your data and results.

6- Start the SAS University Edition vApp

7-Open the SAS University Edition by opening your web browser and typing  http://localhost:10080. From the the SAS University Edition: Information Center, click Start SAS Studio.

There you have it! You have now access to SAS and can start practicing your new programming language.

anayansigamboa sas studio anayansigamboa sas studio anayansigamboa sas studio anayansigamboa sas studio

For more information about the SAS University Edition, see the FAQs and videos at http://support.sas.com/software/products/university-edition/index.html.

For Data Management and EDC training, please contact RA eClinical Solutions.

Anayansi Gamboa has an extensive background in clinical data management as well as experience with different EDC systems including Oracle InForm, InForm Architect, Central Designer, CIS, Clintrial, Medidata Rave, Central Coding, OpenClinica, Open Source and Oracle Clinica.

Disclaimer: The legal entity on this blog is registered as Doing Business As (DBA) – Trade Name – Fictitious Name – Assumed Name as “GAMBOA”.


SAS Cheat Sheet – Part 6

The macro facility is a tool you can use in your programming./*

Macro Language

%DO macro-var=start_value %TO end_value

%DO %WHILE (expression); /*Executes a section of a macro repetitively while a condition is true*/

%DO %UNTIL (expression); /*Executes a section of a macro repetitively until a condition is true*/

Macro variables can be stored in either the global symbol table or in a local symbol table

%GLOBAL macro-variable(s); /*Creates macro variables that are available during the execution of an entire SAS session*/

%IF expression %THEN action; <%ELSE action;> /Conditionally process a portion of a macro*/

%LENGTH (character string | text expression) /*Returns the length of a string*/

The name assigned to a macro variable must be a valid SAS name

%LET macro-variable =<value>; /*Creates a macro variable and assigns it a value*/

%MACRO mname (<pp1><…,ppn><kp1=value<..<kpn=v>);/*Begins a macro definition*/

%MEND <macro-name>; /*Ends a macro definition*/

%SCAN(argument,n<,delimiters>)/*Search for a word that is specified by its position in a string*/

%SUBSTR (argument,position<,length>)/*Produce a substring of a character string*/

%UPCASE (character string | text expression) /*Convert values to uppercase*/

Macro variable values are text values

Macro Quoting

%QUOTE | %NRQUOTE and %BQUOTE | %NRBQUOTE /*Mask special characters and mnemonic operators in a resolved value at macro execution */

%STR | %NRSTR /*Mask special characters and mnemonic operators in constant text at macro compilation */

%SUPERQ /*Masks special characters/mnemonic operators at macro execution but prevents further resolution of the value*/


*----------------------------------------------------------------*//* This macro will produce summary statistics ----------------   */

%Macro safety1;
%odscmd (start,portnum=11,rptname=AEActivityReport);
Data _null_;
fstdate = mdy(month(thedate), 1, year(thedate));
lstdate = intnx(‘month’, fstdate, 1)-1;
call symput (‘strtdate’, put(fstdate, date9.));
call symput (‘stpdate’, put(thedate, date9.));

%put strtdate: &strtdate;
%put stpdate: &stpdate;
* more code goes here;


Concatenating SAS data sets with the APPEND procedure

The APPEND procedure is an efficient method for concatenating observations from a smaller data set to a larger data set. The BASE= data set option is reserved for the larger of the two data sets with the DATA= option for the smaller data set. Essentially, the APPEND procedure avoids reading any observations in the BASE= data set by positioning the record pointer at the end of the BASE= data set.

If no additional processing is necessary, using PROC APPEND or the APPEND statement in PROC DATASETS is more efficient than using a DATA step to concatenate data sets.

Each observation from the smaller data set is then applied one at a time to the end of the BASE= data set. In the next example, the BASE= data set identifies a larger data set called MASTER and the DATA= data set identifies the smaller SOURCEDATA data set.

When one or more variables in the input data set (DATA=) are not present in the BASE= data set, an optional FORCE option can be specified as an option with the PROC APPEND statement to prevent a syntax error


WARNING: Variable charvar has different lengths on BASE and DATA files (BASE 25 DATA 30).
ERROR: No appending done because of anomalies listed above. Use FORCE option to append these files.

As the LOG message suggest, no appending is done and use of the FORCE option is necessary to append the input files. The consequent required syntax to correct this issue would look like this:

DATA=sourcedata force;

WARNING: Variable charvar has different lengths on BASE and DATA files (BASE 25 DATA 30).
NOTE: FORCE is specified, so dropping/truncating will occur.

When two or more data sets need to be concatenated, multiple APPEND procedures are issued. In the next example, two separate PROC APPEND steps are specified to concatenate the two smaller data sets (mysasdata1 and mysasdata2) at the end of the larger BASE= data set.



You cannot use PROC APPEND to add observations to a SAS data set in a sequential library

Reference: SAS 9.2 Language Reference Concepts 2nd edition

From Non-SAS Programmer to SAS Programmer

SAS Programmers come from many different educational backgrounds. Many has started their careers as a Data Manager in a CRO environment and grew to become a SAS programmer. Others have gone to college and pursued degrees in math, statistics or computer science degree.

Do you have SAS Skills? First, you need to find out more about statistical programming desire skills and start to slowly learn what SAS programmers and statisticians do in the pharmaceutical industry. It is also important to understand the Drug Development and Regulatory process so that you have a better understanding of the industry as a whole as well as the drug approval process.

In addition, I have personally attended several workshop on Statistics for Non-statistician provided by several of my past employers/clients (GSK, Sanofi-Aventis, etc) so I could have a greater understanding of statistics role. I am personally more inclined to the EDC development than becoming a biostatistician but these are just some of the few steps you could take to grow your career as a SAS programmer.

Practice, Practice, Practice!

To begin learning how to actually program in SAS, it would be a good idea to enroll to a SAS course provided by the SAS Institute near you or via eLearning. I have taken the course SAS Programming 1: Essentials, and I would recommended. You could also join SUGI conferences and other user groups near your city/country. Seek every opportunity to help you gain further understanding on how to efficiently program in the pharmaceutical industry. It could well land you a Junior SAS programming position.

Transitioning to a SAS Programming role: Now that you have gotten your first SAS programming job, you will need to continue your professional development and attend additional training, workshops, seminars and study workgroup meetings. The SAS Institute provide a second level, more advance course Programming II: Manipulating Data with the Data Step, SAS Macro Language and SAS macro Programming Advanced topics. There are also SAS certifications courses available to help you prepare to become a SAS certified programmer.

There is a light at the end of the tunnel: Advance!

Your ongoing development will be very exciting and challenging. Continued attending SAS classes as needed and attending industry related conferences such as PharmaSUG to gain additional knowledge and insight on how to perform your job more effectively and efficiently.

As you can see, it is possible to ‘grow’ a SAS programmer from a non-programming background to an experience programmer. All of the classes, training, and projects you will work on are crucial in expanding your SAS knowledge and will allow you to have a very exciting career opportunity ahead of you.

Anayansi Gamboa has an extensive background in clinical data management as well as experience with different EDC systems including Oracle InForm, InForm Architect, Central Designer, CIS, Clintrial, Medidata Rave, Central Coding, OpenClinica Open Source and Oracle Clinical.