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

Hello, 

I can't seem to get the labels to show up in my proc print. Here is my code and the output I'm receiving.

 

 

title1 "Subjects Who Died from Heart Failure";
proc print data=hypanl.test;
var wtlb sbp bmi;
label 
SSN = 'Soc Sec Number'
WtLb = 'Subject Weight'
SBP = 'Systolic Blood Pressure';
ID SSN;
run;
 
 
image.png


DATA

 

 

data WORK.TEST;
infile datalines dsd truncover;
input SSN:$11. GenderCd:32. EthCd:$16. RaceCd:$16. EthRaceCd:$3. BirthDt:32. StateCd:$2. VisitDt:32. HtIn:32. WtLb:32. SBP:32. DBP:32. DeathDt:32. ICD10:$6. CODCd:32. HypRelDeathInd:32. BMI:32.;
label SSN="Social Security Number" GenderCd="Gender Code" EthCd="Ethnicity Code" RaceCd="Race Code" EthRaceCd="Ethnicity/Race Code" BirthDt="Birth Date" StateCd="StateCd" VisitDt="Visit Date" HtIn="Height (In)" WtLb="Weight (Lb)" SBP="Systolic BP (mmHg)" D
BP="Diastolic BP (mmHg)" DeathDt="Death Date" ICD10="ICD 10 Code" CODCd="Cause of Death Code" HypRelDeathInd="Hypertension-Related Death";
datalines;
147-48-1068 1 H W HIS 2306 UT 19848 65 158 123 61 . . 0 26.925443787
184-44-2710 1 H W HIS 11974 IA 20012 69.738 174.195 128 74 . . 0 25.788685458
416-08-7584 1 H B HIS 8418 MS 19740 72 176 106 77 . . 0 24.444444444
417-75-1425 1 H W HIS 7205 MS 19983 73 188 106 65 . . 0 25.400638018
417-98-4516 1 H B HIS 1924 MS 19827 67 196 127 74 . . 0 31.436845623
;;;;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You need to specify the LABEL option in the PRINT statement.

 

proc print data=hypanl.test LABEL;

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=proc&docsetTarget=n17dcq1...

 


@ksumbundu wrote:

Hello, 

I can't seem to get the labels to show up in my proc print. Here is my code and the output I'm receiving.

 

 

title1 "Subjects Who Died from Heart Failure";
proc print data=hypanl.test;
var wtlb sbp bmi;
label 
SSN = 'Soc Sec Number'
WtLb = 'Subject Weight'
SBP = 'Systolic Blood Pressure';
ID SSN;
run;
 
 
image.png


DATA

 

 

data WORK.TEST;
infile datalines dsd truncover;
input SSN:$11. GenderCd:32. EthCd:$16. RaceCd:$16. EthRaceCd:$3. BirthDt:32. StateCd:$2. VisitDt:32. HtIn:32. WtLb:32. SBP:32. DBP:32. DeathDt:32. ICD10:$6. CODCd:32. HypRelDeathInd:32. BMI:32.;
label SSN="Social Security Number" GenderCd="Gender Code" EthCd="Ethnicity Code" RaceCd="Race Code" EthRaceCd="Ethnicity/Race Code" BirthDt="Birth Date" StateCd="StateCd" VisitDt="Visit Date" HtIn="Height (In)" WtLb="Weight (Lb)" SBP="Systolic BP (mmHg)" D
BP="Diastolic BP (mmHg)" DeathDt="Death Date" ICD10="ICD 10 Code" CODCd="Cause of Death Code" HypRelDeathInd="Hypertension-Related Death";
datalines;
147-48-1068 1 H W HIS 2306 UT 19848 65 158 123 61 . . 0 26.925443787
184-44-2710 1 H W HIS 11974 IA 20012 69.738 174.195 128 74 . . 0 25.788685458
416-08-7584 1 H B HIS 8418 MS 19740 72 176 106 77 . . 0 24.444444444
417-75-1425 1 H W HIS 7205 MS 19983 73 188 106 65 . . 0 25.400638018
417-98-4516 1 H B HIS 1924 MS 19827 67 196 127 74 . . 0 31.436845623
;;;;

 


 

View solution in original post

5 REPLIES 5
Reeza
Super User

You need to specify the LABEL option in the PRINT statement.

 

proc print data=hypanl.test LABEL;

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=proc&docsetTarget=n17dcq1...

 


@ksumbundu wrote:

Hello, 

I can't seem to get the labels to show up in my proc print. Here is my code and the output I'm receiving.

 

 

title1 "Subjects Who Died from Heart Failure";
proc print data=hypanl.test;
var wtlb sbp bmi;
label 
SSN = 'Soc Sec Number'
WtLb = 'Subject Weight'
SBP = 'Systolic Blood Pressure';
ID SSN;
run;
 
 
image.png


DATA

 

 

data WORK.TEST;
infile datalines dsd truncover;
input SSN:$11. GenderCd:32. EthCd:$16. RaceCd:$16. EthRaceCd:$3. BirthDt:32. StateCd:$2. VisitDt:32. HtIn:32. WtLb:32. SBP:32. DBP:32. DeathDt:32. ICD10:$6. CODCd:32. HypRelDeathInd:32. BMI:32.;
label SSN="Social Security Number" GenderCd="Gender Code" EthCd="Ethnicity Code" RaceCd="Race Code" EthRaceCd="Ethnicity/Race Code" BirthDt="Birth Date" StateCd="StateCd" VisitDt="Visit Date" HtIn="Height (In)" WtLb="Weight (Lb)" SBP="Systolic BP (mmHg)" D
BP="Diastolic BP (mmHg)" DeathDt="Death Date" ICD10="ICD 10 Code" CODCd="Cause of Death Code" HypRelDeathInd="Hypertension-Related Death";
datalines;
147-48-1068 1 H W HIS 2306 UT 19848 65 158 123 61 . . 0 26.925443787
184-44-2710 1 H W HIS 11974 IA 20012 69.738 174.195 128 74 . . 0 25.788685458
416-08-7584 1 H B HIS 8418 MS 19740 72 176 106 77 . . 0 24.444444444
417-75-1425 1 H W HIS 7205 MS 19983 73 188 106 65 . . 0 25.400638018
417-98-4516 1 H B HIS 1924 MS 19827 67 196 127 74 . . 0 31.436845623
;;;;

 


 

ballardw
Super User
proc print data=hypanl.test  LABEL;
var wtlb sbp bmi;
label 
SSN = 'Soc Sec Number'
WtLb = 'Subject Weight'
SBP = 'Systolic Blood Pressure';
ID SSN;
run;
 
 

 

bshiferaw27
Fluorite | Level 6

Hello, 

 Try putting the label on your Proc Print statement. You can also try using this method using the code below. 

I hope this helps!

 

PROC PRINT DATA=dataname

         SPLIT= "*";

         WHERE CODCd =2;

         ID SSN;

         VAR WtLb  BMI  SBP;

         LABEL     SSN     =                'Soc Sec*Number'

                         WtLb    =                'Subject Weight'

                          BMI     =                'Body Mass Index'

                          SBP    =                'Systolic Blood Pressure';

RUN;

traciplummer
Fluorite | Level 6

Hello!

 

Use a label statement to specify the column headers. You want to include a SPLIT = '*' statement to tell SAS where to split, and the split is where the * is. Then make sure to include * in your label statements where you want the label to move to a new line. 

valerieyim
Fluorite | Level 6

Hello,

 

I had the similar issue at the beginning and I fixed it with the following code. I used NOOBS instead of ID statement but I am pretty sure it should do the same thing. 

I added SPLIT statement to make sure that look the same as the homework requirements. 

 

 

Valerie

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 5 replies
  • 1598 views
  • 3 likes
  • 6 in conversation