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

Hello,

 

I'm trying to get the see the frequency of a specific variable characteristics using Proc statements. And nothing is working. Please see some  of my attempts of coding with defining variable characteristics. Please help!

 

Thanks,

LMP

libname mydata "/folders/myfolders"; run;

PROC TABULATE DATA=mydata.v1Mort715;
Class sna2010_na;
TABLES sna2010_na, leadingcau='15' , Tobac='y';
RUN;


Proc freq data=mydata.v1Mort715;
tables   sna2010_na * leadingcau=15;

run;


Proc means data=mydata.v1Mort715;
freq sna2010_na * leadingcau(15) *tobac=y;
run; 
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

So that tells you what the problem is, this:

proc freq data=mydata.v1mort715;
  tables sna2010_na * leadingcau=15;
run;

Is invalid as =15 cannot be part of the tables definition.  Perhaps there is an option you want, options appear after a slash, e.g. if I want and output dataset:

proc freq data=mydata.v1mort715;
  tables sna2010_na * leadingcau / out=want;
run;

 

Examples:

https://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_freq_sect02...

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

"Nothing is working" - this means nothing, what "isn't working", maybe you haven't got the computer switched on for all we know.  This looks fine:

proc freq data=mydata.v1mort715;
  tables sna2010_na * leadingcau=15;
run;

And will print freq output to the listing window, assuming the library/dataset exists and contains those variables.

Also don't code in uppercase.

LMP
Obsidian | Level 7 LMP
Obsidian | Level 7

log error in code sas.PNG

Please see the attached screen shot of the error within the  log for that  particular code.

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

So that tells you what the problem is, this:

proc freq data=mydata.v1mort715;
  tables sna2010_na * leadingcau=15;
run;

Is invalid as =15 cannot be part of the tables definition.  Perhaps there is an option you want, options appear after a slash, e.g. if I want and output dataset:

proc freq data=mydata.v1mort715;
  tables sna2010_na * leadingcau / out=want;
run;

 

Examples:

https://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_freq_sect02...

LMP
Obsidian | Level 7 LMP
Obsidian | Level 7

 Thank you!

ballardw
Super User

Your tabulate code would have ERRORS about variables with undefined roles. Add the other two variables to a CLASS statement;

 

Proc means Freq only allows one variable and it should be one that represents how many times each record is used.

 

In general:

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1076 views
  • 0 likes
  • 3 in conversation