Bill Qualls' LinkedIn Articles

My SAS Programming Tips

  1. Displaying the contents of the Program Data Vector: put (_all_)(=/);
  2. How I deal with temporary variables: useful naming convention, and drop with a wildcard.
  3. Parsing character fields: use of scan and input functions.
  4. IF vs. WHERE - Yes, it matters: their effects on _N_.
  5. Forcing printed output in the event of an empty data file: when it is better to see headers and an empty report than to see nothing at all.
  6. A SAS macro to parse a path into its folder, filename, and extension: and how to read a SAS file given its full path.
  7. Parsing drug dosages: a use case for the anyalpha and substr functions: another data wrangling tip.
  8. Using PROC FORMAT in data munging: it's not just for reporting.
  9. More on PROC FORMAT: writing formats to specific libraries; copying formats from one library to another.
  10. Three SAS Enterprise Guide Options
  11. Simple dedupe of SAS table based on all columns: using NODUPKEY and BY _ALL_
  12. Writing text files to the SAS work library: how and why.
  13. Error message "Insufficient authorization to access C:\WINDOWS\system32\sasgraph.png": How to resolve.
  14. Scoring regression models: PROC SCORE: OUTEST option and PROC SCORE.
  15. Scoring regression models: The "Missing Y" method.
  16. Zero observations imported for .xls file? It opens in Excel but SAS can't read it? How to resolve.
  17. Dates off by ten years? Dealing with Unix/Posix dates.
  18. Is this foreign key valid? (1 of 3) Using PROC FORMAT for data validation.
  19. Is this foreign key valid? (2 of 3) Using the MERGE statement and the IN= option.
  20. Is this foreign key valid? (3 of 3) Using a hash table.
  21. A comprehensive example of using hash tables Not one but two hash tables.
  22. Format blank when zero Also CASE and COALESCE.
  23. Delete rows using PROC SQL. Beware of this gotcha! (Logical vs. physical delete.)
  24. Delete rows using MERGE statement in a DATA STEP. Also BY statement and IN= option.
  25. Looping with do over: looping over (through) an array.
  26. OPTION VARINITCHK: show error message (rather than a note) when variables are not initialized.
  27. Selecting a datetime value into a macro variable, and using that macro variable in a subsequent IF or WHERE statement.
  28. Writing SAS reports to MS Word using ODS RTF FILE and ODS RTF CLOSE.
  29. Using SQLOBS when creating macro variables within PROC SQL.
  30. A simple way to left justify macro variables. (It makes titles look nicer.)
  31. Using IN in a macro IF. (It requires OPTIONS MINOPERATOR.)
  32. Two ways to create an empty SAS dataset: DATA STEP with DELETE and STOP, or PROC SQL with LIKE.
  33. A macro to drop a variable from a SAS dataset if that variable exists. My macro DROP_VAR_IF_EXISTS.
  34. Encoding passwords with PROC PWENCODE.
  35. Using SAS to FTP an external file. My macro FTPFILE, because the FTP access engine was corrupting my files.
  36. %INCLUDE a file if it exists.. (Conditionally include a %INCLUDE file.)
  37. Cross tabulations (crosstabs) using PROC FREQ ). Also ODS NOPROCTITLE, and PROC FREQ options NOCOL, NOROW, and NOPCT.
  38. Using PROC FREQ to conduct a chi-square test of independence. Includes CHISQ option.
  39. Using PROC FREQ to conduct a goodness of fit test. Includes CHISQ and TESTP options.
  40. Using PROC TTEST to conduct a test of hypothesis about a population mean. Includes ALPHA and SIDE options, and how to find the confidence interval of a population mean.
  41. Using PROC FREQ to conduct a test of hypothesis about a population proportion . Also how to find the confidence interval of a population proportion.
  42. K-means clustering in one dimension using PROC FASTCLUS.