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

I have a long and complicated dataset in a .txt file where I can get it to read the dataset and get most of the data in the correct positions in the output. However there is one character variable that sometimes is missing in the .txt file and rather than having no value for that variable in the output, the next variable is just shifted into the missing variable's slot screwing up the remaining data. How do I prevent that from happening while only using where statements in the data step? (var5 is my problem variable and using SAS OnDemand)

 

Example code:

data dataset;
     infile example.txt dlm='09'x;
          input number var1 $ var2 var3 $ var4 $ var5 $ var6 $ var7 $ var8 $ var9 $ var10 $ @;
          drop number;
     run;

 

From example.txt file

1     xxx      1234     xxx     xxx          xxx     xxx     xxx     xxx     xxx
2     xxx      1234     xxx     xxx          xxx     xxx     xxx     xxx     xxx

3     xxx      1234     xxx     xxx     xxx     xxx     xxx     xxx     xxx     xxx

4     xxx      1234     xxx     xxx     xxx     xxx     xxx     xxx     xxx     xxx

5     xxx      1234     xxx     xxx          xxx     xxx     xxx     xxx     xxx

6     xxx      1234     xxx     xxx          xxx     xxx     xxx     xxx     xxx

 

Example output

var1  var2  var3  var4  var5  var6  var7  var8  var9  var10

xxx   1234   xxx   xxx   xxx    xxx    xxx   xxx   xxx    2

xxx   1234   xxx   xxx   xxx    xxx    xxx   xxx   xxx    xxx

xxx   1234   xxx   xxx   xxx    xxx    xxx   xxx   xxx    xxx

xxx   1234   xxx   xxx   xxx    xxx    xxx   xxx   xxx    6

1 ACCEPTED SOLUTION
1 REPLY 1

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 395 views
  • 2 likes
  • 2 in conversation