h1

My first Free SAS® Online Course is now available

September 18, 2016

The new online training environment is now available. It contains my first course: Introduction to SAS® for True Beginner. This SAS online course is free.

Introduction to SAS language for True Beginner

Free SAS Online Course: Introduction to SAS for True beginner

When I started developing this course, I was thinking at junior data managers I used to work with. They had no programming background but they had to work with SAS programmers like me. They had to write specifications detailing what they wanted from programmers. They had to run programs. They had to open SAS tables and extract subsets for review. So I decided to prepare a real course which would help anyone willing to move one step forward in the SAS programming language to face similar situations.

Here is what I’ve prepared for you.

This language has its own vocabulary which just needs to be explained. This way you can speak the same language with your colleagues and use the right keywords when searching for information on the Internet.

I want you to gain a bit of autonomy. It is not really nice to get in touch and ask for help each time you have to run a program, right? So you need to know what is a log and what you should look for in the log file generated by the program. As a minimum, you should also be able to activate/desactive pieces of code in a SAS program.

I also want you to be able to produce by yourself some minimalistic outputs such as .xls file you can use as report. And you can get all this information in this free course.

Just be clear: you’re not gonna see all the basic concepts here. There is no point in writing huge amount of material to start with SAS as it would just anybody down. Your time is precious. I’ve decided to apply the 20/80 concept where 20% of your efforts give you 80% of the results.

I want you to complete the whole course and be able to apply it in your daily tasks. I’ve not selling you a dream. If you want to know more about formats, functions, conditions, merge, data _null_, proc transpose, and so on just watch your email to be informed when the next course is gonna be on sale.

Course Content

So let’s me detail you what this free SAS online course is all about.

It is made of 7 units.

  • 1st unit: I introduce you to the ground vocabulary associated with a table (dataset, library, variable and so on).
  • 2nd unit: you look at the content of a program: global statement, data step, procedures, comments.
  • 3rd unit: you run you first program and look into the output (log and listing files).
  • 4th unit: you filter data in your table to keep only information relevant for you (keep, drop, where, proc sort). You’ll also be introduced to the concept of proc sql.
  • 5th unit: here, you create a few formats and apply them on some variables.
  • 6th unit, you create an .xls output containing data available in your table using ODS syntax.
  • 7th and last unit: you create your first macro and call it. A training is not a training if you cannot give feedback.

How to Register to this Free Course?

To register to this free SAS online course, just create an account by clicking on the top right-hand corner of the screen: Register. Once the form is filled in, you receive an email asking you to confirm your registration and allowing me to send you further information on SAS programming.

Is there any further Courses to become a SAS Expert?

If you want to get deeper into the topic, know several methods to get an expected result, work on programs performances, just be aware that I’m working on additional courses for you to gain a real expertise.

Let’s your Network know about it

If you think that your friends, classmates, colleagues could benefit for this free training, then feel free to share this link: https://hardandsoftskills.com/en/home/

Speak to you soon,

Véronique

h1

SAS 9.2 : Souligner, barrer un texte dans une table avec sortie ODS

July 14, 2011

Avec SAS 9.2 il est maintenant possible de souligner/barrer des valeurs d’une table dans une sortie ODS. Le style TEXTDECORATION est nouvellement disponible.

L’exemple est basé sur une sortie .pdf. TEXTDECORATION=UNDERLINE souligne les valeurs. TEXTDECORATION=LINE-THROUGH barre les valeurs et TEXTDECORATION=OVERLINE (usage très rare a priori) ajoute une ligne au dessus du text.

ods listing close;

ods pdf file=’c:/sasref’;

proc print data=sashelp.class;

var name / display style(column)=[textdecoration=underline];

var sex      / display style(column)=[textdecoration=line-through];

var age      / display style(column)=[textdecoration=overline];

run;

Lectures complementaires

SAS Online Documentation :  Example de codes <a href=’http://support.sas.com/rnd/base/new92/92pdf.html’>http://support.sas.com/rnd/base/new92/92pdf.html</a&gt;

SUGI, pour visualiser le résultat : <a hre=’http://www2.sas.com/proceedings/sugi31/227-31.pdf’>http://www2.sas.com/proceedings/sugi31/227-31.pdf</a&gt;

h1

Summing Missing Values

February 16, 2008

calculator.jpg

Adding two figures and get a different result from your expectation. Yes this is possible with SAS when missing or special missing values are included in your records. Let’s find out the difference between mathematics operators and functions which deals with computation taking the SUM function as an example.


Here is the rule:
SAS functions ignore missing values in their computation. So with the SUM function, the sum of 2 and a missing value is 2, whether it is missing with the + operator: 2 + . = .

Now, I shall detail the three SUM function notation.

1. List values as individual SUM function parameters: parameters of a SAS functions are delimited with commas. To compute the sum of several values, one can list them one after another withint the SUM function brackets using commas as delimiter.

newvar = sum(2,3,.);

Most of the time, the programmer won’t compute raw figures but will refer to values through variables:

newvar = sum(x,y,z);

2. Use the OF keyword to list values without commas : to list the values to sum without comma, the OF keyword must be used.

newvar = sum (of 2 3 .) ;

newvar = sum(of test2 test3 test4);

3. Extension of the notation with the OF keyword : in the previous example variables have a name a common basis and an integer incremented by 1. By defining an interval, listing the first and lasst variable joined by an hyphen, you should be able to save you from a work which become more and more boring as the number of variables increases.

newvar = sum(of test2-test4);

This notation is not specific to the SUM function. It can be used in many occasions such as the keep or drop function, an array, etc.

Important:
Please note how important it is not to forget the OF keyword. In the previous example, SAS would substract variables test4 to variable test2 if the OF keyword would be missing. The sum function would then have a single value.

Further Reading : the MIN and MAX functions and their related operators >< and <> deal the same way as the SUM function and its + operator with missing values.

h1

Uppercase or Lowercase with SAS?

February 9, 2008

uppercase.jpg

When a programming language does not deal the same way with words having different cases, one says it is case-sensitive. What about SAS? Is it case-sensitive?

1. Words not affected by changes in case: most of the time SAS does not deal differently whether uppercase or lowercase is used. Here are a few examples:

  • SAS syntax (data, proc, do, if, filename, etc.)
  • SAS library names (libname orig_data ‘C:/’;)
  • SAS data sets (data demo; set DEMO;)
  • Variables name (age, AGE, Age)

If you look into you metadata using SAS dictionaries or proc contents procedure, you’ll see that all library names follow a standard notation regardless the original input name. Please note the exception of variable names which still appear in dictionaries with their original notation.

Tip: Lowercases are easier to read. Therefore you’re highly recommended to use them. You can save uppercases for special occasions, for recognising bits in your code.

2. Quoted strings are case-sensitive: here are three case-sensitive examples:

  • Values of character variables (cntry=’UK’;)
  • Variables label (label cntry=’Country’;)
  • Data sets labels (data demo (label=(‘Demography Panel’);)

Those three values are strings defined within quotes. Therefore, cntry=’UK’ is different from cntry=’Uk’.

3. Avoid mistakes using two SAS functions, UPCASE and LOWCASE: to check the value of a variable regardless its case, you can make your comparison of standardised records (all uppercased or all lowercased). Otherwise you may end up missing out some records. Two functions are available UPCASE() and LOWCASE().

4. Example using the UPCASE function with a dictionary: I personally use the UPCASE and LOWCASE functions to select records from SAS dictionaries. Here is an example where all records from the TABLES dictionary are selected when they refer to the WORK library.

proc sql ;
select *
from dictionary.tables
where upcase(libname)=’WORK’;
quit;

h1

4 Functions to Remove Blanks

January 29, 2008

The updated version of this post is now available on the new platform http://programmer-pro.com. It is called ‘5 SAS Functions to Remove Blanks‘.

1. Remove leading and trailing blanks using the STRIP function

Understand the old SAS programs and the TRIM and LEFT functions: until SAS 8.2 version, to remove leading blanks from a string, we would have first more them to the end of the string using the LEFT function and remove those trailing blanks with the TRIM function. This has several disadvantages:

  • Two functions had to be used (TRIM and LEFT),
  • The order the functions appears had to be respected. Otherwise the trialing blanks would remain.
  • When this notation was used with am empty string, the result was a string of length 1 instead of 0. The TRIMN function which solves this issue only appeared with SAS 9.

Making the most of the new syntax, the STRIP function: since SAS 9, the STRIP function resolves the three issues. This function is equivalent to TRIMN(LEFT()).

2. Keep an unique blank between words using the COMPBL function: usually a single blank between words of your strings is needed. To remove any unnecessary blanks, you can remove the COMPBL function. If there are many trailing blanks, only one will remain.

3. Remove all the blanks using the COMPRESS function: by default the COMPRESS function remove all the blanks from a string. To remove any other type of character, you can add a second parameter. But this is beyond today’s topic.

4. Remove les x first blanks using RXPARSE et CALL RXCHANGE statements: the following notation can remplace any tect by another one. Here I shall restrict the discussion to blanks. First you have to define the value before and after in RXPARSE function. Then you define the three or even four parameters of the CALL RXCHANGE statement i.e.:

  • recall the definition of RXPARSE,
  • precise teh variable to update
  • specify the number of time to conduct the update.
  • by default the original variable is updated. To create a new variable, a fourth parameter to CALL RXCHANGE can be added. The length of the new variable will be 200 unless it has been specifically defined beforehands.

Tip: Given that it cannot be more changes than characters in the string, the length of the string can be used to define the number of repetitions. This length, when it includes trailing blanks and resolves to 0 when no character is available, can be found using the LENGTHC function.

Example: here is a variable y with length 30, which is set based on the x variable without its six blanks.

data one;
length y $30;
x= ‘ ZZZ ABCD AB ‘ ;
rx=rxparse(” ‘ ‘ to “);
call rxchange (rx,lengthc(x),x,y);
run;