Posts

Showing posts from April, 2009

maxvarlen_macro: Check the Length of all character variables length is LT 200

MAXVARLEN Macro: According to FDA released the Guidance for Industry: Providing Regulatory Submission in Electronic Format – NDAs which was released in Jan 1999, one of the important point to comply with the agency’s regulations is : The length of any character values cannot be more than 200 characters. Here is the macro which will give us the list of character variables whose actual length (not the assigned) is greater than 200. You can use this program to check the maximum length of all variables of any dataset at once. This macro will create a table with list of variables and their length. ***********************************************************************; *** Program: macro_maxvarlen.sas ***; *** Version: 1.0 ***; *** Client: ***; *** Protocol: ***; *** Programmer: sarath Annapareddy ***; *** Date: 22APR2009 ***; *** Purpose: Macro used to check the list of variables whose ***; *** length is GT 200. ***; *** ***; **************************************************...

Proc Compare/Dictionary.Coulmns/Dictionary.Tables.: Program used to compare the SAS datasets in two directories

Image
Here is the new Proc compare.sas program, I have developed ....to compare all the datasets in 2 directories(testing and production) at once and to quick check any mismatches. Proc compare only check if there is any mismatches between the datasets in 2 directories. If any, it reports otherwise it will give us a note saying that: Note: No unequal Values were found. All values compared are exactly equal. See the proc compare snap shot: What if any dataset has the length more than 8, and what if any variable length more than 40 and what if the dataset name has more than 8 characters etc... Proc Compare doesn't address this issue. I have developed the following program to address this issue. It’s a mandatory that we need to follow certain requirements when we are preparing for an electronic submission to the FDA. The following are some of the QC checks FDA requirements: 1) The length of a dataset name & variable name shouldn’t be more than 8 characters. 2) The length data set labe...

Learn SAS Programming

How to determine the executing program name and path programatically: Oftentimes, I was asked to keep the name and path of the executing program in the FOOTNOTE of the generated table or listings.I have always created a macro variable using the %let statement and, then I called the Macro variable in the footnote statement to get the name of the program. Eventhough it is simple.. it may not be suitable when we write application which need to self document... Read more at: http://studysas.blogspot.com/2009/04/how-to-determine-executing-program-name.html ________________________________________________________________________________ How to check if a variable exist or not: In SAS sometimes, we need to check whether the variable is exist in the dataset or not, we usually run the proc contents program and physically check if the variable exist in the dataset or not.If we want to check it programmatically, then use the following code.... Read more at: http://studysas.blogspot.com/2009/04/ho...

How to determine the executing program name and path programatically

Sometimes, we need to keep the name and path of the executing program in the FOOTNOTE of the generated table or listings. I have always created a macro variable using the %let statement and, then I called the Macro variable in the footnote statement to get the name of the program. Eventhough it is simple.. it may not be suitable when we write application which need to self document... Here is another technique which can be used to retrieve the pathname and filename (last executed) ..... To get the last opened filename: proc sql noprint; select scan (xpath,-1, ' \ ') into :progname from sashelp.vextfl where upcase( xpath ) like '%.SAS' ; quit ; %put &progname; result: filename.sas or data _null_; set sashelp.vextfl( where = ( upcase ( xpath ) like '%.SAS' )); call symput ( 'program' , scan ( xpath , - 1 , '\' )); run ; %put &program; result: filename.sas To get path name ... then .. use the following code; ...

How to Check, if the variable exists in the SAS dataset or not

How to check if a variable exist or not: In SAS sometimes, we need to check whether the variable is exist in the dataset or not, we usually run the proc contents program and physically check if the variable exist in the dataset or not. If we want to check it programmatically, then use the following code.... Sample dataset: data old; input ID SCORE1 SCORE2 SCORE3 SCORE4 SCORE5 SCORE6; cards; 24 100 97 99 100 85 85 28 98 87 98 100 44 90 60 100 97 69 100 100 100 65 100 98 100 93 90 100 70 99 97 100 100 95 100 40 97 99 98 49 100 95 190 100 99 97 100 100 90 196 100 100 99 100 100 100 210 98 85 88 90 80 95 100 ; run ; data _null_; dset= open ( ' old ' ); call symput (' chk ',varnum ( dset ,' SCORE4 ')); run ; %put &chk; RESULT:5 Here I have used both OPEN and VARNUM functions in the program to check if SCORE4 variable exists in a 'OLD' dataset. The OPEN function opens a SAS data set and the VARNUM function, which returns the variable's position ...

How to check if the File is exist or not in SAS

How to check if the File is exist or not in SAS: Guys… Let me try explaining how to check if the file exist in the library or directory using SAS. Here I am writing a macro to check if the file exist in the directory or not. Here is the way to check it… % macro check(dir= ) ; %if %sysfunc ( fileexist (&dir)) %then %do; % put File Exists ; % end ; %else %do ; %put File doesn’t exist.; % end ; % mend ; %check (dir=" C:\Documents and Settings\sannapareddy\Desktop\Holidays 2009.docx" ); %sysfunc option empowers me to use the same Data step functions outside the Data step. Almost all of the Data step functions are available to use outside the data step if we use %sysfunc. fileexist option, verifies the existence of an external file. It can also verifies the SAS library. Here is another simple technique to check..... data _null_ ; x= fileexist( 'C:\Documents and Settings\sannapareddy\Desktop\Holidays 2009.docx' ); call symput ( 'myvar1' ,...