DATA Step, Macro, Functions and more

Read raw data w/ special characters

Reply
New Contributor
Posts: 2

Read raw data w/ special characters

[ Edited ]

Raw data

101~lilly\5000
102&jasmine|3000
103:rose /7000

 

I need a data set without special characters with 3 varialbles named  " id name and sal"

 

I created programm like this, but getting error

data a;

infile 'C:\SASUniversityEdition\myfolders\vidya\test1.txt' dlm='~' '\' '&' '|' ':' '/';
input id name $ sal;
run;

 

Please help me to create the correct programm


Dataset.JPG
Super User
Posts: 9,682

Re: Can anyone help me to create program for this raw data

If you are using UE, the path should like this:


data a;
infile '/folders/myfolders/test1.txt' dlm='~' '\' '&' '|' ':' '/';
input id name $ sal;
run;

PROC Star
Posts: 7,363

Re: Can anyone help me to create program for this raw data

You will get errors for at least two reasons: (1) SAS can't find the file and (2) you didn't specify the delimiters properly. Try this instead:

 

data a;
  infile '/folders/myfolders/vidya/test1.txt' dlm='~&|:/\';
  input id name $ sal;
run;

Art, CEO, AnalystFinder.com

 

Ask a Question
Discussion stats
  • 2 replies
  • 132 views
  • 0 likes
  • 3 in conversation