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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 911 views
  • 0 likes
  • 3 in conversation