Help using Base SAS procedures

Continues variable into tertiles

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Continues variable into tertiles

[ Edited ]

Hi all, 

 

I have a total leisure time physical activity (MVPA) as a continues variable. I am trying to create a new MVPA variable that is in tertiles. 


So far this is what I have done

 

proc rank data = recode5;
ranks groups = 3;
var mvpa;
ranks mvpa_tert;
run;

 

But this code is not working....

 

Any help and guidance is greatly appreciated! 

 

Thank you!


Accepted Solutions
Solution
‎03-21-2018 02:49 PM
Super User
Posts: 23,700

Re: Continues variable into tertiles

You didn't specify an output data set in the PROC RANKS statement so the data created is probably called DATA1 or something. 

check your log.

 


@epi101 wrote:

Hi all, 

 

Thank you for the advice. The code seems to run. The  log is not producing any errors. However when I tried to run cross tabulations is saying that  mvpa_tert (my new categorical variable) not found. 

 

Thank you!


 

View solution in original post


All Replies
Super User
Posts: 23,700

Re: Continues variable into tertiles

proc rank data = recode5 groups = 3;
var mvpa;
ranks mvpa_tert;
run;

I think you have a semicolon too early.

 


@epi101 wrote:

Hi all, 

 

I have a total leisure time physical activity (MVPA) as a continues variable. I am trying to create a new MVPA variable that is in tertiles. 


So far this is what I have done

 

proc rank data = recode5;
ranks groups = 3;
var mvpa;
ranks mvpa_tert;
run;

 

But this code is not working....

 

Any help and guidance is greatly appreciated! 

 

Thank you!


 

Super User
Posts: 13,523

Re: Continues variable into tertiles

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.

 

proc rank data = recode5;
ranks groups = 3;
var mvpa;
ranks mvpa_tert;
run;

 

Groups is an option that goes on the Proc Rank statement, not as you have it her

 

Try

proc rank data = recode5
    groups = 3
;
   var mvpa;
   ranks mvpa_tert;
run;

 
Occasional Contributor
Posts: 5

Re: Continues variable into tertiles

[ Edited ]

Hi all, 

 

Thank you for the advice. The code seems to run. The  log is not producing any errors. However when I tried to run cross tabulations is saying that  mvpa_tert (my new categorical variable) not found. 

 

Thank you!

PROC Star
Posts: 8,164

Re: Continues variable into tertiles

You likely didn't run it on the new file created. SAS will automatically supply a name for the file if you don't.

Try:

proc rank data = recode5 out=want groups = 3;
  var mvpa;
  ranks mvpa_tert;
run;

and then do your analyst on file want

 

Art, CEO, AnalystFinder.com

 

Occasional Contributor
Posts: 5

Re: Continues variable into tertiles

It worked!! 

Thank you s much!!

Solution
‎03-21-2018 02:49 PM
Super User
Posts: 23,700

Re: Continues variable into tertiles

You didn't specify an output data set in the PROC RANKS statement so the data created is probably called DATA1 or something. 

check your log.

 


@epi101 wrote:

Hi all, 

 

Thank you for the advice. The code seems to run. The  log is not producing any errors. However when I tried to run cross tabulations is saying that  mvpa_tert (my new categorical variable) not found. 

 

Thank you!


 

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 452 views
  • 2 likes
  • 4 in conversation