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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 377 views
  • 1 like
  • 3 in conversation