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

I tried to submit the code below, but SAS does't show the word after the blank in the values of the variable "COMPLICATION".

Can anyone fix it?

 

data complication;
length SUBJECT 8 COMPLICATION $15;
input SUBJECT COMPLICATION $ ;
datalines;
2076 Pneumonia
3585 DVT(Lower)
3630 DVT(Lower)
4585 Compartment
4599 Aspiration
4760 Acute Resp
4775 Pneumonia
2076 Heart Attack
3585 Pneumonia
3660 Heart Attack
4585 Pneumonia
4599 Pneumonia
4760 Pneumonia
4775 DVT(Lower)
2076 Renal Fail
3585 Renal Fail
3630 Pancreatit
4585 Skin Break
4599 Renal Fail
4760 Renal Fail
4775 Pneumonia
3630 Pneumonia
4775 Renal Fail
;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
brzcol
SAS Employee
data complication;
length Subject 8 Complication $15;
input Subject  Complication & $;
datalines;
2076 Pneumonia
3585 DVT(Lower)
3630 DVT(Lower)
4585 Compartment
4599 Aspiration
4760 Acute Resp
4775 Pneumonia
2076 Heart Attack
3585 Pneumonia
3660 Heart Attack
4585 Pneumonia
4599 Pneumonia
4760 Pneumonia
4775 DVT(Lower)
2076 Renal Fail
3585 Renal Fail
3630 Pancreatit
4585 Skin Break
4599 Renal Fail
4760 Renal Fail
4775 Pneumonia
3630 Pneumonia
4775 Renal Fail
;
run;

What you need to do is add in the & modifier on the input statement since the values include spaces.

 

https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=lestmtsref&docsetTarge...

View solution in original post

5 REPLIES 5
brzcol
SAS Employee
data complication;
length Subject 8 Complication $15;
input Subject  Complication & $;
datalines;
2076 Pneumonia
3585 DVT(Lower)
3630 DVT(Lower)
4585 Compartment
4599 Aspiration
4760 Acute Resp
4775 Pneumonia
2076 Heart Attack
3585 Pneumonia
3660 Heart Attack
4585 Pneumonia
4599 Pneumonia
4760 Pneumonia
4775 DVT(Lower)
2076 Renal Fail
3585 Renal Fail
3630 Pancreatit
4585 Skin Break
4599 Renal Fail
4760 Renal Fail
4775 Pneumonia
3630 Pneumonia
4775 Renal Fail
;
run;

What you need to do is add in the & modifier on the input statement since the values include spaces.

 

https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=lestmtsref&docsetTarge...

Shmuel
Garnet | Level 18

Alternatively to @brzcol solution you can try next code:

data complication;
infile datalines truncover;
length Subject 8 Complication $15;
input Subject  Complication $char15.;
datalines;
2076 Pneumonia
......
; run;
OGA13
Obsidian | Level 7

Thanks very much for your help.

I'm just wondering why do i need to specify the format in the input statement as well?

Reeza
Super User
You're aware the data you have posted is already truncated as well?
OGA13
Obsidian | Level 7
Yes, I do. But thanks for the interest.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 5 replies
  • 1464 views
  • 2 likes
  • 4 in conversation