Bari Lawhorn

3月 202017
 

accessible ODS results with SASLet’s look at the term “accessible” and how it relates to the SAS world. Accessible output is output that can be read by a screen reader to someone with low or no vision, visualized by someone with low vision or color blindness, or navigated by someone with limited mobility. In January of 2017, the United States Access Board published a final rule that documents federal standards and guidelines for accessibility compliance specific to information and communication technology (ICT). The new standards and guidelines update the Section 508 law that was most recently amended in 1998, and adopt many of the Web Content Accessibility Guidelines (WCAG) 2.0 standards. Here’s a comparison document: Comparison Table of WCAG 2.0 to Existing 508 Standards. The final rule (as a parent, I appreciate this rule name!) is also known as the “508 refresh”.

To help SAS US customers comply with the visual-accessibility regulations outlined by the final rule, ODS developers are providing SAS programmers with the ability to create accessible results to present their SAS data. In SAS® 9.4 TS1M4 (9.4M4), there are three great improvements that I would like to highlight:

  • ACCESSIBLE_GRAPH option (preproduction) in the ODS HTML5 statement
  • SAS® Graphics Accelerator
  • ACCESSIBLE option (preproduction) in the ODS PDF statement

Note about “Preproduction” Status: ACCESSIBLE and ACCESSIBLE_GRAPH

Why are the ACCESSIBLE (in the ODS PDF FILE= statement) and ACCESSIBLE_GRAPH (in the ODS HTML5 FILE=statement) options preproduction? By setting the status as preproduction, the development team has greater flexibility to make changes to the syntax and underlying architecture. The development team has worked hard to provide these new features, and is very eager to hear feedback from the SAS programming community. They also encourage feedback from the compliance teams that work for those of you who are striving to make your SAS results accessible. Please request and install SAS 9.4M4 here, and start using these new features to generate your current results in the new formats. Ask your compliance team to assess the output, and let us know (accessibility@sas.com) how close we are to making your files compliant with the final rule.

ODS HTML5

The ODS HTML5 destination, which was introduced in SAS® 9.4, creates the most accessible output in SAS for consumption of tables and graphs on the web. This destination creates SVG graphs from ODS GRAPHICS results. SVG graphics scale when zoomed, which maintains the visual integrity of the image. To ensure that the results comply with the maximum number of WCAG standards, use one of the following styles:

  • DAISY (recommended)
  • VADARK
  • HIGHCONTRAST
  • JOURNAL2

In most cases, these styles provide a high level of contrast in graphics output and tabular output.[1]
When you use an accessibility checker such as the open-source accessibility testing tool aXe, you can see how the HTML5 destination compares to the HTML4 destination (the default destination in SAS® Foundation). Here is a comparison of a simple PRINT procedure step. Using this code, I generate two HTML files, html4.html and html5.html:

ods html file="html4.html" path="c:temp" ;
ods html5 file="html5.html" path="c:temp" style=daisy;
 
proc print data=sashelp.cars(obs=5);
var type origin;
run;
 
ods _all_ close;

 

An aXe analysis in Mozilla Firefox finds the following violations in the html4.html file:

Here is the analysis of the html5.html file:

Your success might vary with more complex procedures. The final paragraph of the blog post describes how to offer feedback after you test your code in the HTML5 destination using SAS 9.4M4.

SAS® Graphics Accelerator

The addition of the ACCESSIBLE_GRAPH preproduction option to the ODS HTML5 statement adds accessibility metadata (tags) around ODS GRAPHICS images routed to the HTML5 destination[2]. This metadata provides the ability to have bar charts, time series plots, heat maps, line charts, scatter plots, and histograms consumed by an exciting new add-in available for the Google Chrome and (coming soon) Firefox browsers: SAS GRAPHICS Accelerator. SAS Graphics Accelerator provides the following capabilities:

  • The interactive exploration of supported graphics using sound
  • The ability to download data in tabular format to a CSV file
  • Customization of visual and auditory settings for alternative presentations

Pay attention to the SAS Graphics Accelerator web page because improvements and features are being offered on a regular basis!

ODS PDF ACCESSIBLE

The web is “where it’s at” for most consumers of your organization’s information. However, many sites need PDF files for results requiring a longer storage time. Prior to SAS 9.4M4, using a screen reader with PDF files created by ODS did not work because the PDF files created by ODS are not “tagged.” Tags in a PDF file are not visible in Adobe Reader when the file is opened. But, when a PDF file is tagged, the file contains underlying metadata to facilitate screen readers verbalizing the results. Here’s an example of the same PROC PRINT step above written to two different PDF files using SAS 9.4M4. I created the tagged.pdf file using the ACCESSIBLE preproduction destination option, so the file includes tags, making it accessible using assistive technology.

ods pdf file="c:tempuntagged_default.pdf";
ods pdf (id=a) file="c:temptagged.pdf" accessible;
 
proc print data=sashelp.cars(obs=5);
var type origin;
run;
 
ods _all_ close;

 

 

To determine whether a PDF file is tagged, open the file and select View ► Show/Hide ► Navigation Panes ► Tags. For example, I checked the untagged_default.pdf file and saw the following, which means that this file is not useful to a screen reader:

Let’s compare the results from the tagged.pdf file:

A screen reader uses the HTML-like markup shown above to verbalize the file to someone with low or no vision.

Adobe Acrobat Pro has built-in accessibility checkers that enable us to examine the degree of accessibility of our files. You can display this setting by selecting View ► Tools ► Accessibility. A full discussion of the Adobe compliance-check features is outside the scope of this article. But, an initial examination of the tagged.pdf file shows that there are many accessible features included in the file, and that two of the features need a manual check:

Check with staff who are well-versed in compliance at your organization, and let us know if our files meet your standards.

I want to see sample code, and hear more! How do I get access to SAS 9.4M4 and more information about these new features?

Your SAS installation representative can order SAS 9.4M4 using the information on this page, Request a Maintenance Release. If you want to get a preview of SAS 9.4M4 to learn it before your site gets it, you can use SAS® University Edition (www.sas.com/universityedition).

Read these upcoming papers (available in April 2017) for code samples. And, if you are attending SAS Global Forum 2017, plan to attend the following presentations:

Here are links to the documentation and a previously published SAS Global Forum paper on the topic:

How did we do?

We welcome feedback regarding the results that you are generating with SAS 9.4M4, and look forward to offering the ODS statement options in production status with improved features and support for more procedures. Please send feedback to accessibility@sas.com.

 

[1] See “ODS HTML5 Statement Options Related to Accessibility” in Creating Accessible SAS 9.4 Output Using ODS and ODS Graphics for more information

 

Create accessible ODS results with SAS or "Why you should be running SAS 9.4m4!" was published on SAS Users.

7月 162016
 

ProblemSolversWhen you work out, you probably have a routine set of exercises that you do. But if you read health-and-fitness websites or talk to a personal trainer, you know that for optimal fitness, you should vary your workout routine. Not only does adding variety to your fitness regime help you prevent injuries, it also helps build muscles by working different parts of your body. For example, if you’re a runner, you could add weights or another resistance workout once or twice a week. If you are a weight lifter, you might add yoga or Pilates to your repertoire to enhance your personal fitness. In a similar way, it can be beneficial for you as a SAS programmer to vary your coding methods by trying new things.

SAS programmers very often use the TEMPLATE procedure to create style templates that use the CLASS and STYLE statements. I am going to help you bulk up your PROC TEMPLATE muscles by showing you how to use the COMPUTE AS and TRANSLATE INTO statements to alter the structure of tables via table definitions.

The COMPUTE AS statement helps you create or modify columns of data. You can use this statement to create a column from raw data (similar to what you can do with the REPORT procedure), or you can use it with an existing table template. The following example uses a PROC TEMPLATE step that illustrates the former. This example uses an existing data set (the CARS data set that is shipped in the SASHELP library) and computes an average-miles-per-gallon variable called MPG_AVG:

proc template;
    define table mytable; 
       column make model mpg_city mpg_highway mpg_avg;
       define mpg_avg;
         header="Avg MPG";
         compute as mean(mpg_city,mpg_highway);
         format=3.;
         style={font_weight=bold};
    end;
    define make;
       blank_dups=on;
    end;
  end;
run;
 
data _null_;
  set sashelp.cars(where=(cylinders=4 and drivetrain="All"));
  file print ods=(template='mytable');
  put _ods_;
run;

Here are partial results from the example code:

Using the COMPUTE AS and TRANSLATE INTO Statements

You’ll notice that I just could not resist sticking with part of my normal PROC TEMPLATE routine when I added a style change to the new column MPG_AVG. I also made the values in that column stand out by using bold font. In addition, because I like to prevent duplicates from appearing, I used the BLANK_DUPS=ON column attribute for the MAKE column.

If you want to try a cool new trick that is available in SAS® 9.4, try the following ODSTABLE procedure. This code does exactly what the previous example does, only with fewer keystrokes. It's similar to combining a strength and cardio move in your exercise routine!

proc odstable
   data=sashelp.cars(where=(cylinders=4 and drivetrain="All"));
   column make model mpg_city mpg_highway mpg_avg;
   define mpg_avg;
      header="Avg MPG";
      compute as mean(mpg_city,mpg_highway);
         format=3.;
         style={font_weight=bold};
   end;
   define make;
      blank_dups=on;
   end;
run;

Most procedures (except for PRINT, REPORT, and TABULATE) use an existing table template. You can determine the table template that a procedure uses by reviewing the log information that is generated when the ODS TRACE ON statement is in effect. For example, based on the log information from an ODS TRACE ON statement, we know that the following MEANS procedure code uses a table template called BASE.SUMMARY.

proc means data=sashelp.cars;
     class drivetrain;
     var mpg_city;
run;

If you submit this PROC MEANS code, you obtain the results shown below:

Using the COMPUTE AS and TRANSLATE INTO Statements02

In the following example, I use the COMPUTE AS statement to edit the MEAN column by multiplying the mean statistic by 10:

proc template;
   edit base.summary;
   edit mean 
      compute as (mean * 10);
         format=6.1;
      end;
   end;
run;

Here are the results that are generated when you run the PROC MEANS step a second time (with an explanatory footnote added):

Using the COMPUTE AS and TRANSLATE INTO Statements06

It is important to note that the default location where PROC TEMPLATE stores results is the SASUSER library. Therefore, subsequent PROC MEANS steps also multiply the mean by 10 unless you delete this table template. Just like a personal trainer recommends stretching after each workout in order to avoid sore muscles, I recommend the following PROC TEMPLATE step to delete the updated table template after the PROC MEANS step:

proc template;
   delete base.summary;
run;

The COMPUTE AS statement is useful when you need to create or edit an entire column. However, in many of the statistical procedures, the reported statistics are stacked. Technical Support has received requests from SAS programmers to make changes to just one of the statistics in a column. Therefore, when you want to change a single cell in a table, I recommend that you exercise the TRANSLATE INTO statement.

Consider the following code in which the Parameter Estimates object is requested from the RELIABILITY procedure:

ods select ParmEst;
 
proc reliability data=fan;
   distribution Weibull;
   pplot lifetime*censor( 1 ) / covb;
run;

Note: The DATA=FAN option in the code above links to the online documentation where you can find the DATA step that builds the data set FAN.

The code above displays the results shown in this table:

Using the COMPUTE AS and TRANSLATE INTO Statements04

In this table, the Estimate column displays the parameter estimates. If you need to modify just one set of parameters (for example, just the Extreme Value [EV] parameter estimates), you can use the TRANSLATE INTO statement to do the job.

The TRANSLATE INTO statement applies conditional logic to effectively change the formatting of the Estimate column only for the EV Location and EV Scale parameters. In the following example, the Estimate column for the EV Location parameter is displayed with the 10.5 format. In addition, the EV Scale parameter is displayed with a 10.6 format, while the remaining cells are displayed with the default format applied, which is specified as 10.4.

proc template;
     edit qc.reliability.ppest;
        edit estimate;
           header="Estimate";
		format=10.4;
           translate (Parameter = 'EV Location') into put(_val_, 10.5),
                   (Parameter = 'EV Scale') into put(_val_, 10.6);
      end;
     end;
run;

When you rerun the PROC RELIABILITY step that is shown above, you get these results:

Using the COMPUTE AS and TRANSLATE INTO Statements05

The changes that you make to your statistics can be much more dramatic. Just like with your workout, the more effort you put into it, the more defined your results!

The samples and SAS Notes found on support.sas.com focus on the DEFINE, STYLE, and CLASS statements in PROC TEMPLATE. These statements are fabulous tools in the PROC TEMPLATE routine that enhance your ODS results because they help change the style of your Excel, HTML, RTF, and PDF results.  By adding the COMPUTE AS and TRANSLATE INTO statements to your tools, you can round out your ODS routine to further enhance your ODS results. But if you find that you need the help of a personal trainer (that is, a Technical Support consultant), call Technical Support or send email to support@sas.com!

Are you ready to enhance your PROC TEMPLATE programming routine even more? If so, here are some additional resources:

tags: Problem Solvers, SAS Programmers

Build your PROC TEMPLATE muscles: Using the COMPUTE AS and TRANSLATE INTO statements was published on SAS Users.

5月 212015
 

If you have programmed with SAS in the last 15 years, you have probably had a reason to share your SAS results in PDF format. The ODS PDF destination, much like a well-designed car, has evolved over the years, offering progressively nicer features like security, enhanced image formatting and embedded fonts. I think you’re going to like what SAS 9.4 has to offer!

Let’s discuss three key SAS 9.4 improvements to this beloved, reliable and top rated ODS destination:

  • Pearl default style
  • ODS LAYOUT statement
  • ODSLIST and ODSTEXT procedures

ODS PDF’s new default style: Not just a pretty paint color.

Just like car manufacturers, the ODS developers have improved the “look and feel” of the PDF destination in SAS 9.4 by updating the default style. Styles.Pearl, the new default style for ODS PDF and ODS PRINTER,  is designed with a more modern feel. The headers are no longer shaded, the borders are lighter and we think you’ll agree the results are much more appealing. Here’s a screen shot showing sample PROC PRINT results comparing the new default style, styles.Pearl, with the earlier default, styles.Printer:

Illustration showing differences in SAS 9.4 default ODS Styles.PEARL and previous default Styles.PRINTER

ODS LAYOUT: Production status with robust documentation

The ODS LAYOUT feature, which allows the precise placement of SAS output on a PDF page, was introduced in SAS 9.2. However, it held so much power and required so many feature improvements, it was released in preproduction status. Since that time the SAS programming community has offered feedback on its performance and features, leading to the SAS 9.4 release where the destination is offered with two distinct models: GRIDDED and ABSOLUTE, both of which offer robust “owner’s manuals”.

We think the ABSOLUTE model will be the most popular. You can use it to place tables and images side by side, stack them top to bottom and even overlay output in your PDF files, and works to create output placed on a single PDF page.  The GRIDDED model is more useful when using BY-group data and/or creating multi page output.

The ABSOLUTE LAYOUT syntax uses a pair of ODS LAYOUT statements (ODS LAYOUT START and ODS LAYOUT END) to define the area on the page to which you will write ODS REGIONs.  ODS REGION statements define the location and size of regions to which you will write tables, text or images. Both statements use the X= argument to define the horizontal “start” position, and Y= to define the vertical start position of your output. If you do not use either of these, the output starts in the upper left corner (0,0). Height= and Width= arguments can be used on both statements to control the size of the layouts and regions.

Here is sample code for defining a sleek layout page within your ODS PDF destination:

  • Create a PDF file with FILE=, turn off the bookmark/table of contents with NOTOC, and with NOGTITLE make all Graph titles part of the PDF file, instead of embedding them in the Graph images.
    ods pdf file="file.pdf" notoc nogtitle ;
  • Define a LAYOUT that is 7.25 inches high and 10.5 inches wide.  The keyword ABSOLUTE is not necessary as it is implied if neither the COLUMNS= nor the ROWS= option is used. Previously we have set the system option ORIENTATION= to LANDSCAPE on an OPTIONS statement and set a Title and Footnote, whose text will be placed outside the layout.
    ods layout start height=7.25in width=10.5in ;
  • Define the first REGION. The region is placed inside my layout, starting .75 inch from my top margin (y=.75in) and one inch from my left margin (x=1in). This region is allocated 3.5inches of space across my page (width=3.5in).
    ods region x=1in y=.75in width=3.5in ;

The ODS LAYOUT and REGION statements used above are part of Sample 55808.  We’ll use the full code to generate the following output from SAS 9.4, and I’ll explain how to assemble all the pieces using other new features in SAS 9.4:

SAS 9.4 ODS output using ODS LAYOUT statement

PROC ODSTEXT: easily insert paragraphs of text

The ODSTEXT procedure helps us format paragraph text that would previously have been written with DATA _null_ / FILE PRINT logic or ODS <destination> TEXT= syntax. However, neither of these methods allow for elegant style control and line spacing, nor do either of those strategies integrate well with the table of contents.  Now using PROC ODSTEXT, we can format paragraphs of text (or just single words if preferred!), with ease.

Here’s the first PROC ODSTEXT code used in our screen shot shown above:

  
proc odstext;
    p "The ODSTEXT procedure offers a powerful tool for inserting paragraph style text into your ODS destinations. "  / style=systemtitle;
    p  "The ODSTEXT procedure allows us to: format text with style control offered with the statement option style=,  use data sets, and add bullets."  / style=systemtitle;
    p '  ';
    p "A close sibling is PROC ODSLIST, used to generate the following bulleted list of improved ODS PDF features:" /  style=header;
run;

Here are the results:

PROC ODSTEXT output showing three sizes and

PROC ODSLIST: easily create bulleted lists

Closely related to the ODSTEXT procedure is PROC ODSLIST, which allows us to create nicely formatted, indented and bulleted lists from a SAS dataset. Here’s an example:

 proc odslist data=features;
   item feature /style={bullet="disc"};
   end;
 run;

Here are the results:

PROC ODSLIST output
There’s an added bonus in SAS 9.4: the ODSLIST and ODSTEXT procedures can be used in ANY of the non-LISTING ODS destinations.  Try them out in ODS POWERPOINT and ODS RTF too!

Adding the bar chart to our layout

The image in our PDF file is created with the PROC SGPLOT and highlights a feature new in SAS 9.4, the SYMBOLCHAR statement.  The data and program are described in Sample 54315 and a recent Problem Solvers blog. The key to sizing and inserting the output in the upper right corner of our PDF file is specifying the following ODS REGION statement and the ODS GRAPHICS statement height= option before the PROC SGPLOT code.

ods region x=4in y=.5in ; 
ods graphics on / reset noborder height=3.5in;

Adding the table to the PDF

The bottom table is created by PROC REPORT along with some “power assist” from PROCs ODSTEST and FORMAT. This region is defined only with a Y= specification as I want REPORT’s table to take up the width of the entire region. The REPORT table will be centered by default, but ODSTEXT= will not, hence the j=c style override.

ods region y=4in; 

proc format;
value myfmt low-40="^{style [foreground=red] ^{unicode 2193} "
           40-high="^{style [foreground=green] ^{unicode 2191} ";
run;

proc odstext ;
   p " ";
   p "A subset of SASHELP.CARS where MPG_HIGHWAY is greater than 40 " / style={font=(", Albany",10pt,bold) just=c};
 run;

proc report data=sashelp.cars(where=(mpg_highway gt 40 and cylinders eq 4)) spanrows
style(report)={posttext="^{style [font_weight=bold] PROC FORMAT uses inline formatting and the Unicode style function to differentiate models based on the combined MPG}" };
col make model mpg_highway mpg_city avg type enginesize horsepower drivetrain;
define make / order;
define avg  / computed "Combined MPG" format=8. style(column)={posttext=myfmt.};
compute avg;
   avg=sum(mpg_highway.sum,mpg_city.sum)/2;
endcomp;
run;

Here are the results:

Using ODS LAYOUT feature to create and place a PROC REPORT table
We “put the brakes on” by closing the LAYOUT and the PDF destination:

ods layout end;
ods pdf close;

I hope you have enjoyed “kicking the tires” on my favorite destination. Are you excited about getting this new and updated model? If so, give your SAS dealership (ahem, representative) a call and upgrade today!

Please read the fine print:

If you have been an intrepid ODS LAYOUT coder prior to SAS 9.4, you are likely to see different results from your ODS LAYOUT/REGION statements when you move to SAS 9.4. If using the legacy style, styles.printer, does not correct the results, use Scott Huntley’s paper “An Insider’s Guide to ODS LAYOUT Using SAS® 9.4” . It is an excellent resource for coders moving ODS LAYOUT code from previous releases.

If you are moving from a SAS release prior to version 9.2, Scott and I wrote this paper “Getting the Right Report (Again): Your Compatibility Guide for ODS PDF 9.2” to discuss changes that took place for ODS PDF in that version.

Scott and Woody Middleton introduce you to the new features for ODS PDF in SAS 9.3 in "A Different Point of View with ODS PDF in SAS®9.3".

SAS has provided printable tip sheets for ODS PDF, ODS LAYOUT, PROC ODSTEXT, PROC ODSLIST, ODS GRAPHICS and more.

tags: ods, Problem Solvers, reporting, SAS 9.4, SAS Programmers

The post ODS PDF destination in SAS 9.4: Come take a look under the hood! appeared first on SAS Users.

9月 272014
 

If you live in an English speaking country you are used to a relatively unadorned alphabet. Take a look at the French and Spanish languages, where vowels are decorated with accents like “acción” in Spanish, and the circumflex, or the hat used in “pâte” in French. Look at the gorgeous scripting you get to use if you read and write the letter "a" in Japanese: あ . Nice looking, right?

If you work with data that originates from another country or is distributed across the globe, you need to know about the SAS system options that control how the characters in your data are stored. Two of these options are ENCODING and LOCALE. These options will help guarantee that if your Japanese counterpart sends you SAS information in Japanese, you see the appropriate output, and not a series of question marks or blank boxes in your SAS session, or worse, errors in your log window.

The ENCODING system option instructs SAS how to store the data created by SAS in that session and how to read data from external sources. The LOCALE system option instructs SAS how to represent currency, date and time values, how to display menu items and tasks, and sets default papersize and timezone values.

What exactly is encoding?

Encoding is not a term SAS invented. It is the way that characters are represented by computers. This  W3C Internationalization page is an excellent non-SAS resource if you’d like to study the concept  further.

Many encoding values exist in SAS, so that in combination with the LOCALE option setting, SAS will run in over 100 countries with SAS windows, pmenus and log messages localized accordingly. The SBCS, DBCS, and Unicode Encoding Values for Transcoding Data is a table of the current encoding values for SAS 9.4.

For example, if I invoke SAS with the LOCALE setting of Korean and an encoding value of euc-kr, I will see notes, warnings and errors written to my log in Korean:

NOTE: 변수 'a'이(가) 초기화되지 않았습니다.

The above text is translated to English as:

Note: Variable a is not initialized

Why is encoding important?

The ENCODING system option is important to SAS programmers because its setting determines how individual characters are represented by SAS.  As an illustration, on Windows, using an encoding of Wlatin1, the character “á” is stored in the 255th place. However when running a Unicode (UTF8) encoding session of SAS, the same value is stored internally in the 195th place:

/*RANK Function: */
/*Returns the position of a character in the ASCII collating sequence. */

data test;
 x='á';
 y=getoption('encoding');
 z= rank(x);
 put x=;
 put y=;
 put z=;
run;

x=á x=á
y=WLATIN1 y=UTF-8
z=225 z=195

What is the default encoding value?

As stated previously, the encoding value is set based upon the value of LOCALE, and the regional settings selected in the SAS Deployment Wizard during installation and deployment of SAS software, as shown here:

encoding1

On Windows and UNIX machines, the SAS 9.4 Intelligence Platform installation provides the Locale Setup Manager task in the SAS Deployment Manager to configure the language and region for SAS Foundation and certain SAS applications.  See the  SAS(R) 9.4 Intelligence Platform: Installation and Configuration Guide for more information.

The SAS Technical Paper Multilingual Computing with SAS® 9.4 explains how SAS is deployed for National Language Support.  Three images are automatically deployed for SAS on all Windows and UNIX machines:

  • ‘English’ is a single-byte SAS image that displays an English User Interface and English messages by default. The LOCALE and ENCODING options for the English image are set to match the Regional settings or, if the Regional Settings selection is an Asian language, it sets LOCALE and ENCODING to support en_US.
  • ‘English with DBCS’ is a double-byte SAS image that displays English User Interface and English SAS messages by default. This image supports languages that require a double-byte character set, such as Chinese. If a double-byte language is selected later in the Regional Settings dialog, the LOCALE option in the ‘English with DBCS support’ config file is set to match. Otherwise, the LOCALE defaults to ja_JP.
  • ‘Unicode Support’ is installed for all Windows and UNIX deployments, even if the SAS server is not configured for Unicode support. The ENCODING option is set to utf-8. The LOCALE of the Unicode server is set to match the Regional Settings locale selection.

What if my encoding differs from others with whom I share SAS data?

You could encounter this error because the data set encoding does not match the SAS session encoding:

ERROR: Some character data was lost during transcoding in the data set

A comparison of the PROC OPTIONS group=LANGUAGECONTROL settings with the dataset’s encoding will help determine what steps you should take to ensure you can access and modify the data set in question.  This SAS Note 52716 discusses the lost character data error in detail.

The most common method of preventing this error is to launch SAS using a different configuration file, so that the encoding for the SAS session matches that of the dataset.  Alternatively, requesting data in a different format (i.e., different encoding) is feasible as well.

The logic shown in SAS Note 15597 shows logic to convert the encoding of a SAS data set. However, if it is the case that you will be sharing data with different languages and encoding values, it is imperative that you communicate with those with whom you share data and SAS files to ensure that the SAS system settings you use consistently allow you seamless access to shared data.

What if I have non-SAS data sources?

If you read or access data from a database such as Oracle, it is imperative that your data base client communicates with SAS in order to correctly interpret native characters.   SAS note 51411 tells how to correct a potential problem for both Windows and UNIX systems, and may require the input of your data base administrator. The SAS Technical Paper Multilingual Computing with SAS® 9.4 describes configuration steps for many other data base clients.

Where can I find more information on this topic?

tags: ENCODING system option, LOCALE system option, NLS support, Problem Solvers, SAS Programmers