BookmarkSubscribeRSS Feed
sasnewbie85
Calcite | Level 5

Hello there,

 

I recently restarted up my MPH after a long hiatus, and my SAS brain has completely atrophied!  I am working on what should be a very easy procedure, however, I can't seem to get the syntax right.

I have four categories of tobacco consumption, coded 1 2 3 and 4.  I want to have 2 categories, low and high, with the first two (1 and 2) being low and the second 2 (3 and 4) being high.  I need to do this to calculate measures of association between use and obesity.  I was able to do this easily with the two category variable of case or control. 

 

 

6 REPLIES 6
novinosrin
Tourmaline | Level 20

Are you by chance asking how to write the syntax for proc format?

sasnewbie85
Calcite | Level 5

I think so? again, this is all very new (again) to me.

novinosrin
Tourmaline | Level 20

hmm

 

is this what you are asking

 


  proc format;
     value frmt 1,2   = 'Low'
                3,4   = 'High';

  run;

  data test;
  do i=1 to 4;
  output;
  end;
  format i frmt.;
  run;

or

want=put(i,frmt.);

 

data test;
  do i=1 to 4;
  want=put(i,frmt.);
  output;
  end;
  run;

 

 

 

sasnewbie85
Calcite | Level 5

I will get back to you tomorrow morning when I am back at it...thank you so much for your help!

sasnewbie85
Calcite | Level 5

I'm actually not worried about the format, but the observations.  I want them grouped by level of tobacco use.  I have four categories now, and I want two, high and low.  

 

This below yields the tables and statistics I want but with four categories of tobacco use instead of 2, because that is how they are organized.

 

proc print data = work.hw2;
run;
proc freq data = hw2;
tables Tob * Case/ measures;
title;
run;

novinosrin
Tourmaline | Level 20

Without knowing the data, it's very difficult to imagine. It would help if you could post a sample of your data(a few records) alongside explaining your requirement i.e what you want to accomplish based on the sample. An output sample would make it convenient

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1259 views
  • 0 likes
  • 2 in conversation