Hello everyone,
Nowadays, I’m trying to create dynamic code process in my SAS project. I have a macro variable which includes 4 columns name(In my real data, it includes many columns, this is my sample code), some of these columns are numeric and some of the other columns are character, in this macro variable.
I want to seperate the character and numeric columns from each other in the macro variable. If I can do this, I want to send character type variables to the PROC FREQ procedure, and send to numeric type variables to the PROC MEANS procedure.
Is it possible to create this or similar structure in my foregoing sentences?
My sample code as below.
I would be so pleased, if I can get useful help from you.
Data Have;
Length Numeric1 8 Numeric2 8 Character1 $ 32 Character2 $ 32;
Infile Datalines Missover;
Input Numeric1 Numeric2 Character1 Character2;
Datalines;
0.2 0.4 1 0
0.3 0.5 1 2
0.4 0.8 3 1
0.6 0.9 0 2
0.2 0.1 4 3
0.3 0.1 3 2
0.7 0.1 1 4
0.1 0.8 3 3
;
Run;
%Let Variable=Numeric1 Numeric1 Character1 Character2;
OPTIONS NOLABEL;
ODS OUTPUT Summary=Result;
PROC MEANS DATA=Have MEAN STD MIN MAX N NMISS P1 P5 MEDIAN P95 P99 STACKODSOUTPUT;
VAR Numeric1 Numeric2;
RUN;
Ods Trace On;
PROC FREQ Data=Have;
Tables Character1 Character2/ NoCum Missing;
Ods Output OneWayFreqs=Want;
Run;
Ods Trace Off;
Thank you,
Lastly, I tried to seperate the varibles by using PROC CONTENTS OUT= but I'm stopped up, maybe it is not possible, or I need hep
%Let Variable = Numeric1 Numeric2 Character1 Character2; Proc Contents Data=Have Out=Intermediate Noprint; Run; Data Want ; Set Intermediate /*END=Eof*/; Where Type=2 And Name Contains "&Variable." ; Run;
Thank you
... View more