BookmarkSubscribeRSS Feed
sachin05t
Calcite | Level 5
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.

3 REPLIES 3
Reeza
Super User
This code doesn't really do anything...where are you expecting something to happen? It creates a format and copies the file over but that's all.

Please comment your code with what you expect to be happening. This looks a lot like homework, so it's definitely preferable if you show a strong attempt first.
sachin05t
Calcite | Level 5

Sure..I will make more attempts. We were taught Sort and Format today. 

Kurt_Bremser
Super User

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:

  • test
  • site
  • type
  • of
  • imaging

You create work.hw6, but sort hw.hw6.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 949 views
  • 0 likes
  • 3 in conversation