BookmarkSubscribeRSS Feed
hugoyamauchi
Calcite | Level 5

So first I need to rename necessary columns in two of my data sets. In the Apple file, column track_name to App, size_bytes to Size, user_rating to Rating, prime_genre to Genres for my Google data set to match it. I also need price but both of them has the same variable. 

 

 

7 REPLIES 7
PeterClemmensen
Tourmaline | Level 20

@hugoyamauchi Hi and welcome to the SAS Community 🙂

 

Most users here will not download files. Are you able to post a sample of your data in usable form? And describe in detail what your desired result looks like?

hugoyamauchi
Calcite | Level 5
1track_namesize_bytespriceuser_ratingprime_genre 
2PAC-MAN Premium1007882243.994Games 
3Evernote - stay organized15857868804Productivity 
4WeatherBug - Local Weather, Radar, Maps, Alerts10052403203.5Weather

How about this? I want the title of the columns to be changed with the ones that I mentioned before.

It would be great if every single coding steps are shown. 

So I tried to do this: 

data=work.import;
set work (rename=(track_name=App));
run; 

but this came out: ERROR 180-322: Statement is not valid or it is used out of proper order.

PeterClemmensen
Tourmaline | Level 20

Is your only purpose here to rename variables?

hugoyamauchi
Calcite | Level 5

As of now yes but I also need to append them and joined them using SQL.

Aku
Obsidian | Level 7 Aku
Obsidian | Level 7

You are having = -sign in data step, it should be :

 

data work.import;
set work (rename=(track_name=App));
run;

Kurt_Bremser
Super User

Don't rename after the fact, set when reading in the first place. See this:

data applestore;
infile datalines firstobs=2 dlm=',' dsd;
input
  obsnum
  id :$9.
  track_name :$50.
  size_bytes
  currency :$3.
  price
  rating_count_tot
  rating_count_ver
  user_rating
  user_rating_ver
  ver :$10.
  cont_rating :$5.
  prime_genre :$15.
  sup_devices_num
  ipadSc_urls_num
  lang_num
  vpp_lic
;
datalines;
"","id","track_name","size_bytes","currency","price","rating_count_tot","rating_count_ver","user_rating","user_rating_ver","ver","cont_rating","prime_genre","sup_devices.num","ipadSc_urls.num","lang.num","vpp_lic"
"1","281656475","PAC-MAN Premium",100788224,"USD",3.99,21292,26,4,4.5,"6.3.5","4+","Games",38,5,10,1
"2","281796108","Evernote - stay organized",158578688,"USD",0,161065,26,4,3.5,"8.2.2","4+","Productivity",37,5,23,1
"3","281940292","WeatherBug - Local Weather, Radar, Maps, Alerts",100524032,"USD",0,188583,2822,3.5,4.5,"5.0.0","4+","Weather",37,5,3,1
"4","282614216","eBay: Best App to Buy, Sell, Save! Online Shopping",128512000,"USD",0,262241,649,4,4.5,"5.10.0","12+","Shopping",37,5,9,1
;

data googleplaystore;
infile datalines firstobs=2 dlm=',' dsd;
input
  App :$50.
  Category :$20.
  Rating
  Reviews
  Size :$15.
  Installs :$15.
  Type :$10.
  Price
  Content_Rating :$15.
  Genres :$50.
  Last_Updated :anydtdte25.
  Current_Ver :$20.
  Android_Ver :$20.
;
format
  Last_Updated yymmddd10.
;
datalines4;
App,Category,Rating,Reviews,Size,Installs,Type,Price,Content Rating,Genres,Last Updated,Current Ver,Android Ver
Photo Editor & Candy Camera & Grid & ScrapBook,ART_AND_DESIGN,4.1,159,19M,"10,000+",Free,0,Everyone,Art & Design,"January 7, 2018",1.0.0,4.0.3 and up
Coloring book moana,ART_AND_DESIGN,3.9,967,14M,"500,000+",Free,0,Everyone,Art & Design;Pretend Play,"January 15, 2018",2.0.0,4.0.3 and up
Sketch - Draw & Paint,ART_AND_DESIGN,4.5,215644,25M,"50,000,000+",Free,0,Teen,Art & Design,"June 8, 2018",Varies with device,4.2 and up
;;;;

Adapt the names in the input and format statements as needed.

ballardw
Super User

Hint: Paste examples of text files like CSV into a code box opened on the forum with the {I} icon so you get something like:

name,sex,age,height,weight
Alfred ,M ,14,69,112.5
Alice ,F ,13,56.5,84
Barbara ,F ,13,65.3,98
Carol ,F ,14,62.8,102.5
Henry ,M ,14,63.5,102.5
James ,M ,12,57.3,83

Then we can see your data without downloading it. Also because of a variety of issues between the forum and such the CSV may only be "viewed" as a spreadsheet. Which in some cases has a potential for making the data look different than it actually is and can them be difficult to trace down what you see when attempting something versus what we have available.

 

Since CSV are not data sets they do not actually have "variable names" yet, only column headers. When you read the CSV into a SAS data set then you get variables. So read the CSV so that the correct variable names are used in the first place. At the same time you should also make sure that properties like variable type, numeric or character, and lengths are the same if the intent is to combine this data.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 7 replies
  • 1601 views
  • 2 likes
  • 5 in conversation