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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 5 replies
  • 804 views
  • 0 likes
  • 3 in conversation