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

libname learn xlsx '/folders/myshortcuts/s2/hosp.xlsx';
proc report data=learn.hosp nowd headline;
column subject AdmitDAte DOB Age;
define AdmitDate/"Admission Date" width=10;
define DOB/width=3 ;
define subject/display width=7;
define Age/computed "Age at admission" ;
compute Age;
Age=round(yrdif(DOB,AdmitDate,'Actual'));
endcomp;
run;

 

log consists of following statements:

Variable DOB is uninitialized.
NOTE: Variable AdmitDate is uninitialized.
 
Output:
In output Age is comming as missing variriable.
 
Please help me out with this situation.Please refer the screenshot for output.

doubt.png
1 ACCEPTED SOLUTION

Accepted Solutions
ArtC
Rhodochrosite | Level 12

The define usage of a report item is assigned to each variable individually.  You have verified that DOB is numeric, therefore its default define usage is ANALYSIS.  Character variables have a default usage of DISPLAY.  For completeness i like to always specify the define usage on each DEFINE statement - even when i think that it is redundant.

 

The problem specifically for you in this case is that for report items with a define usage of ANALYSIS their names are not used directly within a compute block.  You can read more about this here:

http://www.sascommunity.org/wiki/In_The_Compute_Block:_Issues_Associated_with_Using_and_Naming_Varia...

The variable names are used explicitly when the usage is DISPLAY.

View solution in original post

3 REPLIES 3
s_m
Obsidian | Level 7 s_m
Obsidian | Level 7
After adding display in DOB and AdmitDate Code is working fine.Value for Age is coming.Please explain why we need display for this.I have already mention display for subject,So it will automatically force display for all other variables.Why only after adding display Age is being computed?
ArtC
Rhodochrosite | Level 12

The define usage of a report item is assigned to each variable individually.  You have verified that DOB is numeric, therefore its default define usage is ANALYSIS.  Character variables have a default usage of DISPLAY.  For completeness i like to always specify the define usage on each DEFINE statement - even when i think that it is redundant.

 

The problem specifically for you in this case is that for report items with a define usage of ANALYSIS their names are not used directly within a compute block.  You can read more about this here:

http://www.sascommunity.org/wiki/In_The_Compute_Block:_Issues_Associated_with_Using_and_Naming_Varia...

The variable names are used explicitly when the usage is DISPLAY.

ArtC
Rhodochrosite | Level 12
in your picture (doubt.png), the variable labels are being displayed. It is possible that DOB is the label and not the actual variable name. The same may be true for AdmitDate.

Also make sure that both are SAS dates.

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

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 1432 views
  • 1 like
  • 2 in conversation