libname HW 'C:\Desktop';
proc format;
value $TestSite 'LS'='Lumbar-Spine' 'T'='Thoracic';
Value $TypeOfImaging 1='MRI' 2='CT' 3='Plain';
format test site $TestSite. Type of Imaging $TypeOfImaging.;
Data HW6;
Set HW.HW6;
proc sort data=hw.hw6 nodupkey;
by DOS;
proc print;
run;
There are 4 variables:
PATID – Patient ID
DOS – Date of Service
TestSite – test Site: LS=Lumbar-Spine, T=Thoracic
TypeOfImaging – Type of Imaging: 1=MRI, 2=CT, 3=Plain
It is possible that a patient may have more than 1 entry on the same date of service.
I am trying to write a program so that:
A. Create a SAS data set so that a patient may not have more than 1 entry on the same date of service.
B. Create 2 formats: 1 for TestSite and 1 for TypeOfImaging so that their values will be listed in full details when PRINT procedure is used.
C. Use PRINT procedure to print out the data with full details of the values.
Not sure where the error lies.
Sure..I will make more attempts. We were taught Sort and Format today.
The format statement is a data step statement, not for open code or proc format.
This:
format test site $TestSite. Type of Imaging $TypeOfImaging.;
would also mean you have the following variables:
You create work.hw6, but sort hw.hw6.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.