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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

6 REPLIES 6
Reeza
Super User
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!


 

ballardw
Super User

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;

 
epi101
Fluorite | Level 6

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!

art297
Opal | Level 21

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

 

epi101
Fluorite | Level 6

It worked!! 

Thank you s much!!

Reeza
Super User

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!


 

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 15022 views
  • 2 likes
  • 4 in conversation