Hi, I have a pretty dense dataset that I would like to organize so I can run proc univariate or proc freq reports on it.
I would like to the first report to find the number of reads (obs) per machine per Mode. And the second report to find the number of reads per Machine per Mode per Study. So I would like to try to create a dummy variable to make that easier, I put two columns to show what I think the dummy variables should look like, but I am not sure whether this is the best way. Any advice is much appreciated!
A sample of the dataset is below:
Mode Study Machine Dummy1?? Dummy2??
EN A M1 EN-M1 EN-M1-A
EN A M2 EN-M2 EN-M1-A
EN B M1 EN-M1 EN-M1-B
HIS A M3 HIS-M3 HIS-M3-A
HIS C M3 HIS-M3 HIS-M3-C
HIS C M2 HIS-M2 HIS-M3-C
MR B M1 MR-M1 MR-M1-B
MR D M2 MR-M2 MR-M2-D
MR D M2 MR-M2 MR-M2-D
MR D M3 MR-M3 MR-M3-D
Depends on what you mean by 'nice report' but it's definitely possible. The results are also in data sets want1, want2.
You could wrap the code in ODS EXCEL and see how that works:
I find tabulate easier to control though.
ods excel file='/folders/myfolders/demo.xlsx';
{code from previous post};
{OR proc tabulate code};
ods excel close;
None of this is necessary, nor is it a good idea.
PROC FREQ does all of this, without any dummy variables at all.
Not sure why you need dummy variables. See the want/want2 data set or output from the following. The LIST option tells SAS to arrange it in a list rather than cross tab.
proc freq data=have /*noprint*/;
table mode*machine / list out=want1;
table mode*machine*study/ list out=want2;
run;
Hi Reeza,
I see, that makes more sense. Is it possible to then export this into an excel file so that it looks like a nice report with Proc Freq?
Depends on what you mean by 'nice report' but it's definitely possible. The results are also in data sets want1, want2.
You could wrap the code in ODS EXCEL and see how that works:
I find tabulate easier to control though.
ods excel file='/folders/myfolders/demo.xlsx';
{code from previous post};
{OR proc tabulate code};
ods excel close;
Thank you, Reeza! I am going to go ahead and try that now
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.