BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kmardinian
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

None of this is necessary, nor is it a good idea.

 

PROC FREQ does all of this, without any dummy variables at all.

--
Paige Miller
Reeza
Super User

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;

kmardinian
Quartz | Level 8

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?

Reeza
Super User

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;
kmardinian
Quartz | Level 8

Thank you, Reeza! I am going to go ahead and try that now

Reeza
Super User
If you really want the dummy variables, use CATX().

Dummy1 = CATX('-', Mode, Machine);

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 728 views
  • 2 likes
  • 3 in conversation