Hi everyone, i have a data set similar to below with 60 columns(both numeric and character). I'm planning to take then in to loop one by one and perform descriptive analysis. before they enter into the loop they must undergo a checking for their datatype. This is an interesting task which i'm planning to perform by the help of using arrays(as I've heard of the power of using arrays and used before).
After going through several white papers i have came up with a sample untested code and it would be great to have your help to take my array learning to a next level.
Kindly do comment.
input subjid AGE SEX BMI SODIUM INFECTION;
01001 56 F 22.3 34.5 Y
01001 60 M 29.3 41.5 N
01001 35 F 26.3 22.5 Y;
01001 23 M 19.3 34.5 Y;
01001 34 F 18.3 41.5 Y;
%macro descriptive(first=, last= );
array variables AGE--INFECTION;
%do over variables;
%if datatyp(variables[i] eq CHARACTER) %then %do;
proc freq data=temp;
%else %if datatyp(variables[i] eq NUMERIC) %then %do;
proc means data =temp;
Some references for you:
Here's a tutorial on using Arrays in SAS
UCLA introductory tutorial on macro variables and macros
Tutorial on converting a working program to a macro
This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it 🙂 https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md
Examples of common macro usage
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.