Posts

Showing posts from April, 2010

WARNING: You may have unbalanced quotation marks.

Image
SAS can allow the strings up to 32,767 characters long but some times SAS will write a Warning message ‘ WARNING: The quoted string currently being processed has become more than 262 characters long. You may have unbalanced quotation marks. ’ , when you try to keep a character string longer than 262 characters to a variable.  It is hard to look back at the SAS code to search for unbalanced quotes. To make it more clearly I am going to show an example. I want to add a 263 characters long name to a variable (longvar) and to do that I will simply use a data step… and when I do that I will see the WARNING message in Log. data TEST; x=" (SEE DOCTOR'S LETTER)3RD ADMINISTRATION OF MTX WAS DELAYED BY 14 DAYS AND WAS REDUCED TO 1G/M2 INSTEAD OF 5G/M2, PROBLEMS, E.COLI SEPSIS WITH HEART INSUFFICIENCY WITH SINUS TACHYCARDY, PARALYTIC ILEUS, TACHYPNEA , PATIENT DIED ON 21.04.98 FROM MULTIORGAN FAILURE. "; y=length(x); put x; run ; LOG FILE: There is a SAS option (NOQUO...

CALL EXECUTE: Easy way to print or sort multiple files.

When printing multiple files, or sorting multiple datasets, the traditional method is to write multiple steps as below. Proc print data =libref.ae; var _all_; run; Proc print data =libref.conmed; var _all_; run; Proc print data =libref.demog; var _all_; run; Proc print data =libref.lab; var _all_; run; Proc print data =libref.medhist; var _all_; run; If you are like me who likes to simplify the traditional SAS code here is the tip. CALL EXECUTE comes to rescue here. *Using Disctionary Tables and Call Execute; proc sql ; create table dsn as select distinct memname from dictionary.tables where libname=" LIBREF " and memtype=" DATA "; quit ; *Sorts all the datasets using Call Execute; data _null_ ; set dsn; call execute (" proc sort data=final .||'memname||'; by usubjid; run ;"); run ; *Prints all the datasets using Call Execute; data _null_ ; set dsn; call execute (" proc print data=final .||...

Write a Letter using SAS/ Emailing with SAS

SAS can do many things which most of us don’t have a clue. Here is one example…. Writing a letter: filename formltr ' C:\Documents and Settings\sreddy\Desktop\formltr.rtf ' ; data address; infile datalines; input @ 1 stno  @ 6 lane $12. @ 19 aptno $7. @ 27 city $9. @ 37 state $2. @ 40 zip ; datalines ; 2550 Augusta Blvd Apt#203 Fairfield OH 45014 ; run ; data _null_; retain lm 5; set address; file formltr;* print notitles; put _page_; adr1 = trim(stno) ' ' trim(lane); put @lm adr1; adr2 = trim(aptno); put @lm adr2; adr3 = trim(city) ||', '|| trim(state) ||' '|| trim(zip); put @lm adr3; adr4 = trim('Dear')|| ' ' ||trim('SAS') || ' ' || trim('Users,'); put / @lm adr4; put / @lm ' StudySAS Blog offers a lot of information regarding tips and tutorials on various topics ' ; put @lm ' in SAS. It covers basics to get started to more in-depth topics like Mac...

Special Missing Values in SAS

Image
Definition: Special missing value is a type of numeric missing value that enables you to represent different categories of missing data by using the letters A-Z or an underscore. Ref: SAS 9.1.3 language reference: concepts page no: 102 The symbol usually used to represent a missing value for a numerical variable is the period or dot. Aside from the dot, there are 27 special missing values SAS can store in numerical variables. They are the dot-underscore (._), and dot-letter (.A thru .Z). Note that these special values are case insensitive. That is, .A=.a .B=.b .C=.c etc . If you do not begin a special numeric missing value with a period, SAS identifies it as a variable name. Therefore, to use a special numeric missing value in a SAS expression or assignment statement, you must begin the value with a period, followed by the letter or underscore, as in the following example: x= .d ; When SAS prints a special missing value, it prints only the letter. When data values contain character...