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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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