BookmarkSubscribeRSS Feed
flyingsohigh
Calcite | Level 5

hi,

 

I need to read in a text file with a layout as below into sas. The sas data should have columns as "Product_productid","Review_userId","Review_ProfileName", "Review_helpfulness","Review_Score", "Review Time", "Review Summary". Can someone let me know how I can handle such case? Thanks!

 

Data format

product/productId: B001E4KFG0
review/userId: A3SGXH7AUHU8GW
review/profileName: delmartian
review/helpfulness: 1/1
review/score: 5.0
review/time: 1303862400
review/summary: Good Quality Dog Food review/text: I have bought several of the Vitality canned dog food products and have found them all to be of good quality. The product looks more like a stew than a processed meat and it smells better. My Labrador is finicky and she appreciates this product better than most.
 

where

 

  • product/productId: asin, e.g. amazon.com/dp/B001E4KFG0
  • review/userId: id of the user, e.g. A3SGXH7AUHU8GW
  • review/profileName: name of the user
  • review/helpfulness: fraction of users who found the review helpful
  • review/score: rating of the product
  • review/time: time of the review (unix time)
  • review/summary: review summary
  • review/text: text of the review

 

 

3 REPLIES 3
Reeza
Super User
Is this the exact structure? You'll have multiple lines after that all follow the structure? Is the last line, the text line, does it have a maximum length limit?

The reason I'm asking is because it's easy to write code that will read the lines above, but it may not generalize to your actual data so it's better to get the details ahead of time.


Here's a couple of different methods outlined here:
https://documentation.sas.com/?docsetId=basess&docsetTarget=p0s16wvzu0z9q7n0zmxia30s6qyc.htm&docsetV...

flyingsohigh
Calcite | Level 5

Thank you for replying to my post. However, I cannot open the link. There is not a limit set to the text so I might just set to the maximum sas allows.

Reeza
Super User

Ok, well your SAS installation should have the documentation installed.

 

It's under SAS Products>Base SAS>Step-by-Step Programming with Base SAS 9.4 ... > Getting your data into Shape> Starting with Raw Data: Beyond the Basics> Reading Multiple Records to Create a Single Observation

 

 

Not sure why you can't access the SAS documentation. 

Or you can search for that topic as well: "Reading Multiple Records to Create a Single Observation".

 


@flyingsohigh wrote:

Thank you for replying to my post. However, I cannot open the link. There is not a limit set to the text so I might just set to the maximum sas allows.


 

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
  • 750 views
  • 0 likes
  • 2 in conversation