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

data have;

input product_code product_1 product_id;

datalines;

1011/1234                        abc  99

1011                                  def    88

1023/4098/7778/8989      gcj      76

;

run;

 

data want;

input product_code product_1 product_id;

datalines;

1011        abc  99

1234       abc  99

1011      def    88

1023      gcj      76

4098      gcj      76

7778      gcj      76

8989      gcj      76

;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

You need

  • function countw to get the number of "words" / product_codes
  • a loop
  • function scan to extract the codes from the list
  • output-statement

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User
 69         data have;
 70         input product_code product_1 product_id;
 71         datalines;
 
 NOTE: Invalid data for product_code in line 72 1-9.
 NOTE: Invalid data for product_1 in line 72 34-36.
 REGEL:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                     
 72         1011/1234                        abc  99
 product_code=. product_1=. product_id=99 _ERROR_=1 _N_=1
 NOTE: Invalid data for product_1 in line 73 39-41.
 73         1011                                  def    88
 product_code=1011 product_1=. product_id=88 _ERROR_=1 _N_=2
 NOTE: Invalid data for product_code in line 74 1-19.
 NOTE: Invalid data for product_1 in line 74 26-28.
 74         1023/4098/7778/8989      gcj      76
 product_code=. product_1=. product_id=76 _ERROR_=1 _N_=3

As a very important learning experience, fix this first.

andreas_lds
Jade | Level 19

You need

  • function countw to get the number of "words" / product_codes
  • a loop
  • function scan to extract the codes from the list
  • output-statement

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
  • 3 replies
  • 823 views
  • 1 like
  • 3 in conversation