BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

In the following examples  there are  columns (char) with  delimiter.

Why the data sets are not created well?

data example1;
infile datalines dlm="|" dsd;
input var1 $ ;
datalines;
ABC|2015|XYZ
ABC||XYZ
;
run;

data example2;
input var1 $ ;
datalines;
ABC,2015,XYZ
ABC,XYZ
;
run;

 

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

What did you expect from this code? What is your desired result?

Ronein
Onyx | Level 15

Look at the values in the data set that was created.

Do you see that the values are not matched to values that I entered 

 

andreas_lds
Jade | Level 19

If the char used a delimiter between variable can appear in char variables as content, then that content has to be enclosed in quotes. If it is not quoted, return the file to the one who created it, explaining that such garbage could be processed, but requires more time to write the code and requires additional to verify the result.

Shmuel
Garnet | Level 18

You have 3 variables per row, then change your code to:

data example1;
informat var1-var3 $5.;
infile datalines dlm="|" dsd;
input var1 var2 var3 ;
datalines;
ABC|2015|XYZ
ABC||XYZ
;
run;
Tom
Super User Tom
Super User

What output do you want?

Your current programs are just reading the first value from the data lines. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1270 views
  • 0 likes
  • 5 in conversation