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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.