Write and run SAS programs in your web browser

Proc statements with defining measures

Accepted Solution Solved
Reply
Highlighted
Occasional Contributor LMP
Occasional Contributor
Posts: 18
Accepted Solution

Proc statements with defining measures

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; 

Accepted Solutions
Solution
‎02-02-2018 10:37 AM
Super User
Super User
Posts: 9,384

Re: Proc statements with defining measures

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


All Replies
Super User
Super User
Posts: 9,384

Re: Proc statements with defining measures

"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.

Occasional Contributor LMP
Occasional Contributor
Posts: 18

Re: Proc statements with defining measures

log error in code sas.PNG

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

 

Solution
‎02-02-2018 10:37 AM
Super User
Super User
Posts: 9,384

Re: Proc statements with defining measures

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...

Occasional Contributor LMP
Occasional Contributor
Posts: 18

Re: Proc statements with defining measures

 Thank you!

Super User
Posts: 13,283

Re: Proc statements with defining measures

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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