BookmarkSubscribeRSS Feed
vipendra
Calcite | Level 5
Hi All,
URGENT !!!
 
Please check my code where i write code in input format to get the data.
Code gives me the output but there are some information which is skipped.
 
Please find the attachment of Code, Log & result / Output. 
Please look into the result, I am not getting why City, State, Country, Date etc. column data is skipped.
Code:
 
data get_US_Company_Dataset;
infile '/home/vipendratripathi60/sasuser.v94/Vipen Raw Data Files/US_Company_Dataset.csv' dlm=',' dsd missover firstobs=2 lrecl=50;
length company_name_id $30 company_name city $30 state $2 country $2 company_type $20;
informat date_of_audit mmddyy8.;
input company_name_id company_name year_founded city state country zip_code company_type date_of_audit;
format date_of_audit mmddyy8.;
proc print;
run;
 
 
Regards
Vipendra (vipendratripathi6@gmail.com)
11 REPLIES 11
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

Hello @vipendra and welcome to the community.  your sample is unviewable.

Please post you SAS code and sample data in the manner that we can view and use it to assist you.

 


Maxims of Maximally Efficient SAS Programmers
https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers...

How to convert datasets to data steps
https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

The macro for direct download
https://gist.githubusercontent.com/statgeek/bcc55940dd825a13b9c8ca40a904cba9/raw/865d2cf18f5150b8e88...

How to post code
https://communities.sas.com/t5/help/faqpage/faq-category-id/posting#posting

vipendra
Calcite | Level 5
thanks for raising the point, I have added my codes in description box.
Please look into this.
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13




vipendra
Calcite | Level 5

Edited as suggested, PDF attachment is for your reference as i am unable to attach in HTML file.

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

in your length statement what is the length of company_name?

 

length company_name_id $30 company_name city $30 state $2 country $2 company_type $20;

vipendra
Calcite | Level 5

Its again $30, I have updated in code also.

But my concern is why data is missing or incomplete.

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

@vipendra you have lrecl = 50.  Is that really the length of each record?  Or have you not allowed for the 51--?? positions?

 

vipendra
Calcite | Level 5
i want full data in output. and I even don't know how LRECL works.

do you mean each record = each cells in excel ?
if yes then each cells does not exceeds the limit of 30 words in my file.
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

@vipendra try to change the lrecl = 50 to lrecl = 256 or something longer,  the lrecl = 50 only allows you to obtain the first 50 positions in the record.

 

what you are getting is

company_name_id $30 company_name for a length of $20 which equals your record length of 50.  if your company_name is $30 then those company_names over 20 in length are being chopped off at the end or truncated as one would say.

 

in the above you say that company_name is $30 but in this link you have company_name with a length of $40

https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-Expecting-a-name/m-p/530456#M145073

 

 

try this:

data get_US_Company_Dataset;
infile '/home/vipendratripathi60/sasuser.v94/Vipen Raw Data Files/US_Company_Dataset.csv' dlm=',' dsd missover firstobs=2 lrecl=256;
length company_name_id $30 company_name  $30 city $30 state $2 country $2 company_type $20;
informat date_of_audit mmddyy8.;
input company_name_id company_name year_founded city state country zip_code company_type date_of_audit;
format date_of_audit mmddyy8.;
run;
proc print;
run;

 

Reeza
Super User

LRECL is the length of the record to read. A length of 50 says to read only 50 characters. 

You don’t actually need that option. Uploads should be working soon to add attachments, but you can embed an image directly using the ‘photos’ in the editor. 

 

You can also try PROC IMPORT with GUESSINGROWS=MAX and then compare the generated code in the log to yours and find the mistake. 

 


@vipendra wrote:
i want full data in output. and I even don't know how LRECL works.

do you mean each record = each cells in excel ?
if yes then each cells does not exceeds the limit of 30 words in my file.

 

Kurt_Bremser
Super User

@vipendra wrote:

Edited as suggested, PDF attachment is for your reference as i am unable to attach in HTML file.


You do NOT need to use an attachment for code, logs or data from a csv file, as all are pure text.

Post the csv into a window opened with the {i} button, and code into one opened with the "little running man" icon.

I cannot open your pdf, there's a "virus scan in progress" next to the attachment.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 11 replies
  • 1663 views
  • 0 likes
  • 4 in conversation