BookmarkSubscribeRSS Feed
srikanthyadav44
Quartz | Level 8

dear all

i have the data in the following style 

company_nameyearNIC
20 Microns Ltd.20118
Ashapura Minechem Ltd.20118
A D F Foods Ltd.201110
Adani Wilmar Ltd.201110
Agro Tech Foods Ltd.201110
Ajanta Soya Ltd.201110
Ambar Protein Inds. Ltd.201110
Andrew Yule & Co. Ltd.201110
Arcuttipore Tea Co. Ltd.201110
Avanti Feeds Ltd.201110
B & A Ltd.201110
B C L Industries Ltd.201110
Bajaj Hindusthan Sugar Ltd.201110
Balrampur Chini Mills Ltd.201110
Bambino Agro Inds. Ltd.201110
Bannari Amman Sugars Ltd.201110
Bengal Tea & Fabrics Ltd.201110
Britannia Industries Ltd.201110
C C L Products (India) Ltd.201110
Chordia Food Products Ltd.201110
Coastal Corporation Ltd.201110
Coromandel Agro Products & Oils Ltd.201110
D C M Shriram Inds. Ltd.201110
D F M Foods Ltd.201110
Dalmia Bharat Sugar & Inds. Ltd.201110
Davangere Sugar Co. Ltd.201110
Dhampur Sugar Mills Ltd.201110
Dharani Sugars & Chemicals Ltd.201110
Dharti Proteins Ltd.201110
Diana Tea Co. Ltd.201110
Divya Jyoti Inds. Ltd.201110
Duncans Industries Ltd.201110
Dwarikesh Sugar Inds. Ltd.201110
E I D-Parry (India) Ltd.201110
Eastern Sugar & Inds. Ltd.201110
Empee Sugars & Chemicals Ltd.201110
Foods & Inns Ltd.201110
Hindustan Foods Ltd.201110
Kashipur Sugar Mills Ltd.201110
Kings Infra Ventures Ltd.201110
Kothari Fermentation & Biochem Ltd.201110
Madhur Industries Ltd.201110
Nimbus Foods Inds. Ltd.201110
Norben Tea & Exports Ltd.201110
Prima Agro Ltd.201110
Sagar Soya Products Ltd.201110
Sampre Nutritions Ltd.201110
Shah Foods Ltd.201110
Spectrum Foods Ltd.201110
Associated Alcohols & Breweries Ltd.201111
Devyani International Ltd.201111
Eco Friendly Food Processing Park Ltd.201111
Elegant Floriculture & Agrotech (India) Ltd.201111
Flex Foods Ltd.201111
G M Breweries Ltd.201111
G R M Overseas Ltd.201111
Naturite Agro Products Ltd.201111
Orient Beverages Ltd.201111
S I P Industries Ltd.201111
Sinnar Bidi Udyog Ltd.201111
Tarai Foods Ltd.201111
Freshtrop Fruits Ltd.201112
Sree Jayalakshmi Autospin Ltd.201112
A I Champdany Inds. Ltd.201113
A K Spintex Ltd.201113
A P M Industries Ltd.201113
Aarvee Denims & Exports Ltd.201113
Aditya Spinners Ltd.201113
Alka India Ltd.201113
Alok Industries Ltd.201113
Alps Industries Ltd.201113
Amarjothi Spinning Mills Ltd.201113
Ambika Cotton Mills Ltd.201113
Anjani Synthetics Ltd.201113
Arex Industries Ltd.201113
Arvind Ltd.201113
Asahi Industries Ltd.201113
Ashima Ltd.201113
Ashnoor Textile Mills Ltd.201113
B S L Ltd.201113
Bannari Amman Spg. Mills Ltd.201113
Banswara Syntex Ltd.201113
Betex India Ltd.201113
Bhandari Hosiery Exports Ltd.201113
Bharat Textiles & Proofing Inds. Ltd.201113
Binayak Tex Processors Ltd.201113
Birla Cotsyn (India) Ltd.201113
Birla Transasia Carpets Ltd.201113
Blue Blends (India) Ltd.201113
Budge Budge Co. Ltd.201113
C L C Industries Ltd.201113
Cheviot Co. Ltd.201113
Damodar Industries Ltd.201113
Dhanlaxmi Fabrics Ltd.201113
Donear Industries Ltd.201113
Eastern Silk Inds. Ltd.201113
Eskay K'N'It (India) Ltd.201113
Faze Three Autofab Ltd.201113
Faze Three Ltd.201113

the first variable is character variable and remaining two are numeric variables. 

can anybody suggest me how to create data lines.

i tried with the below mentioned code, but it is not giving proper data structure as shown in the above table.

 

 

data have;
input company_name$ year NIC;
datalines;

run;

 

thanking you in advance 

10 REPLIES 10
PaigeMiller
Diamond | Level 26

In my opinion, the easiest way to do this is to follow these instructions:

 

https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/

--
Paige Miller
Kurt_Bremser
Super User

You need to insert the data after the DATALINES statement. Since you have blanks in the character column, you need to use a delimiter other than a blank, and add an INFILE DATALINES statement with the proper DLM= option.

srikanthyadav44
Quartz | Level 8
dear Mr.KUrt_Bremser
could you please give me one sample code for this purpose
Kurt_Bremser
Super User

I will not insult your intelligence by spoon-feeding you such simple code. Please try it yourself with the advice I already gave you (after 132 posts here, it can't be that hard any longer). Also consult the documentation of the INFILE Statement .

And add a LENGTH statement for company_name; the default length of 8 will be too short.

PaigeMiller
Diamond | Level 26

@srikanthyadav44 wrote:
dear Mr.KUrt_Bremser
could you please give me one sample code for this purpose

@maguiremq has provided an example of DATALINES in your other thread.

--
Paige Miller
Tom
Super User Tom
Super User

It is not clear what you are asking for.  How is it that you have the data now?

Is it just in the tabular word file type structure you posted into your message?  If so copy the lines and paste them after the DATALINES statement and before the statement with the semi-colon that ends the lines of in-line data.  Then change any TAB characters that might be there to make it look like a table in WORD or EXCEL with some other more useful character, such as | or comma.   For example in SAS Display Manager interactive usage you can just use the change command.

change '09'x '|' all

Then add an INFILE statement and make sure to define the first variable long enough (or give SAS a hint on how to GUESS what length to define).

data want;
  infile datalines dsd dlm='|' truncover;
  input company_name :$60. year NIC ;
datalines;
20 Microns Ltd.|2011|8
Ashapura Minechem Ltd.|2011|8
;

Is it already in a SAS dataset and you are asking how to generate text you could paste into the program to send to someone to recreate the data?  Just use a data _NULL_ step and the PUT statement.  Use a FILE statement so you can set a delimiter.

data _null_;
  file log dsd dlm='|';
  put company_name year nic;
run;

Then just copy the lines from the SAS log and paste them into your data step.

srikanthyadav44
Quartz | Level 8

can you please let me know how to use

change '09'x '|' all

if i am using SAS on demand version.

 

thanking you in advance.

Kurt_Bremser
Super User

In SAS On Demand, you use SAS Studio, so the commands for the "old" editor of the Display Manager interface will not work.

But as long as your data does not contain tabs, using tabs as delimiters will be fine.

Tom
Super User Tom
Super User

You can do it with the GUI tools in SAS/Studio.  You have to highlight and copy one of the tab characters from the program editor and paste it into the Find What box of the Find/Replace tool.  It will just look like a bunch of spaces, but it works.

Example:  Here is a program with tab characters:

Tom_0-1659454039571.png

 

And here you can seem them replaced with pipe characters.

Tom_0-1659453648244.png

 

AllanBowe
Barite | Level 11

This macro will convert a dataset to a cards program:  https://core.sasjs.io/mp__ds2cards_8sas.html

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 10 replies
  • 1053 views
  • 0 likes
  • 5 in conversation