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

Hi,

I have successfully updated this dat file but the first observation is the variables (see attachment).

 

This is the code I have used it:

DATA patients;
INFILE '/.../uis.dat';
INPUT id $ age $ gender;
RUN;

 

How can I fix this?

 

Thanks!

 

1 ACCEPTED SOLUTION
4 REPLIES 4
Sou1
Fluorite | Level 6

Thanks so much!!

: )))))

Kurt_Bremser
Super User

Given what I saw in your screenshot, I suggest changes to your code:

data patients;
infile '/.../uis.dat' firstobs=2;
input id $ age gender $;
run;

as age is always numeric, and gender might actually be a character value. Once you know what is in the character columns, you can adapt the lengths by using a informat.

I also guess that the trailing n for the physical filename is not needed.

 

BTW, you do not need to encapsulate screenshots in Word documents. Save your screenshot as a picture, and use the "camera" icon to insert the picture directly in your post. Word documents make it harder for many of us to view the picture, as corporate firewalls block the download of a .docx and/or the use of the previewer (as that works on a cloud storage service)

sdhilip
Quartz | Level 8
Hi

You can use this

DATA patients;
INFILE '/.../uis.dat';
INPUT id $ age $ gender;
RUN;

Data patient_new;
set patients(firstobs = 2);
run;

This will create a dataset from the second observation

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
  • 4 replies
  • 960 views
  • 0 likes
  • 3 in conversation